<commit_before>/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/
package lucee.runtime.tag;

import lucee.runtime.PageSource;
import lucee.runtime.err.ErrorPage;
import lucee.runtime.err.ErrorPageImpl;
import lucee.runtime.exp.ExpressionException;
import lucee.runtime.exp.MissingIncludeException;
import lucee.runtime.ext.tag.TagImpl;

/**
 * Enables the display of customized HTML pages when errors occur. This lets you maintain a
 * consistent look and feel within your application, even when errors occur.
 *
 *
 *
 **/
public final class Error extends TagImpl {

	private ErrorPageImpl errorPage = new ErrorPageImpl();

	@Override
	public void release() {
		super.release();
		errorPage = new ErrorPageImpl();
		// exception="any";
		// template=null;
		// mailto="";

	}

	/**
	 * set the value exception Type of exception. Required if type = "exception" or "monitor".
	 * 
	 * @param exception value to set
	 **/
	public void setException(String exception) {
		errorPage.setTypeAsString(exception.toLowerCase().trim());
		// this.exception=exception.toLowerCase().trim();
	}

	/**
	 * set the value type The type of error that the custom error page handles.
	 * 
	 * @param type value to set
	 * @throws ExpressionException
	 **/
	public void setType(String type) throws ExpressionException {
		type = type.toLowerCase().trim();
		if (type.equals("exception")) {
			errorPage.setType(ErrorPage.TYPE_EXCEPTION);
		}
		else if (type.equals("request")) {
			errorPage.setType(ErrorPage.TYPE_REQUEST);
		}
		// else if(type.equals("validation")) this.type=VALIDATION;
		else throw new ExpressionException("invalid type [" + type + "] for tag error, use one of the following types [exception,request]");
	}

	/**
	 * set the value template The relative path to the custom error page.
	 * 
	 * @param template value to set
	 * @throws MissingIncludeException
	 **/
	public void setTemplate(String template) throws MissingIncludeException {
		PageSource ps = pageContext.getCurrentPageSource().getRealPage(template);
		if (!ps.exists()) throw new MissingIncludeException(ps);
		errorPage.setTemplate(ps);
	}

	/**
	 * set the value mailto The e-mail address of the administrator to notify of the error. The value is
	 * available to your custom error page in the MailTo property of the error object.
	 * 
	 * @param mailto value to set
	 **/
	public void setMailto(String mailto) {
		errorPage.setMailto(mailto);<commit_msg>format cferror exception<commit_after>/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/
package lucee.runtime.tag;

import lucee.runtime.PageSource;
import lucee.runtime.err.ErrorPage;
import lucee.runtime.err.ErrorPageImpl;
import lucee.runtime.exp.ExpressionException;
import lucee.runtime.exp.MissingIncludeException;
import lucee.runtime.ext.tag.TagImpl;

/**
 * Enables the display of customized HTML pages when errors occur. This lets you maintain a
 * consistent look and feel within your application, even when errors occur.
 *
 *
 *
 **/
public final class Error extends TagImpl {

	private ErrorPageImpl errorPage = new ErrorPageImpl();

	@Override
	public void release() {
		super.release();
		errorPage = new ErrorPageImpl();
		// exception="any";
		// template=null;
		// mailto="";

	}

	/**
	 * set the value exception Type of exception. Required if type = "exception" or "monitor".
	 * 
	 * @param exception value to set
	 **/
	public void setException(String exception) {
		errorPage.setTypeAsString(exception.toLowerCase().trim());
		// this.exception=exception.toLowerCase().trim();
	}

	/**
	 * set the value type The type of error that the custom error page handles.
	 * 
	 * @param type value to set
	 * @throws ExpressionException
	 **/
	public void setType(String type) throws ExpressionException {
		type = type.toLowerCase().trim();
		if (type.equals("exception")) {
			errorPage.setType(ErrorPage.TYPE_EXCEPTION);
		}
		else if (type.equals("request")) {
			errorPage.setType(ErrorPage.TYPE_REQUEST);
		}
		// else if(type.equals("validation")) this.type=VALIDATION;
		else throw new ExpressionException("Invalid type [" + type + "] for tag [error], use one of the following types [exception, request]");
	}

	/**
	 * set the value template The relative path to the custom error page.
	 * 
	 * @param template value to set
	 * @throws MissingIncludeException
	 **/
	public void setTemplate(String template) throws MissingIncludeException {
		PageSource ps = pageContext.getCurrentPageSource().getRealPage(template);
		if (!ps.exists()) throw new MissingIncludeException(ps);
		errorPage.setTemplate(ps);
	}

	/**
	 * set the value mailto The e-mail address of the administrator to notify of the error. The value is
	 * available to your custom error page in the MailTo property of the error object.
	 * 
	 * @param mailto value to set
	 **/
	public void setMailto(String mailto) {
		errorPage.setMailto(mailto);
{'fraction_non_alphanumeric': 0.09904458598726115, 'fraction_numerical': 0.001910828025477707, 'mean_word_length': 3.9691455696202533, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5823228', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1704, 'n_words': 662}