Location: PHPKode > scripts > Noostr > _engine/handlers/error.php
<?php defined('SYSPATH') OR die('No direct access to this file is allowed.');
/**
 * Error handling.
 *
 * @package Noostr
 * @subpackage Handler_Error
 */

/**
 * Custom error handler, so we can do fancy things when problems appear.
 *
 * @param mixed $code
 * @param mixed $message
 * @param mixed $file
 * @param mixed $line
 * @return bool Returns TRUE if we don't want to capture the error.
 */
function error_handler($code, $message, $file, $line) {
	if (0 == error_reporting()) {
		return true;
	}
	switch ($code) {
		case E_WARNING:
		case E_NOTICE:
			//return true;
	}
	echo "<br />CODE: $code -> #$line, $file<br /><em>$message</em><br />\n";
	throw new ErrorException($message, 0, $code, $file, $line);
}

/**
 * Custom exception handler, so we can do fancy things when problems appear.
 *
 * @param Exception $e
 */
function exception_handler($e) {
	try {
		echo "<br /><strong>Uncaught exception in <em>".$e->getFile()."</em>:</strong> " , $e->getMessage(), " on line ".$e->getLine()."\n";
	} catch (Exception $e) {
		print get_class($e)." thrown within the exception handler. Message: ".$e->getMessage()." on line ".$e->getLine();
	}
}

function errors($err) {
	$return = false;
	$err = make_array($err);
	for ($i = 0, $c = count($err); $i < $c; $i++) {
		if (trim($err[$i]) != '') {
			$class = 'err err_'.$err[$i];
			switch ($err[$i]) {
				case 'ape01':
					$return .= '<p class="'.$class.'">The title is a required field.</p>';
					break;
				case 'a01':
					$return .= '<p class="'.$class.'">You do not have permission to view that page.</p>';
					break;
				case 'c01':
					$return .= '<p class="'.$class.'">There was a problem with your entry. Please try again.</p>';
					break;
				case 'd01':
					$return .= '<p class="'.$class.'">You must be logged in to be able to delete content. <a href="/login">Click here</a> to login or sign up.</p>';
					break;
				case 'd02':
					$return .= '<p class="'.$class.'">You do not have permission to delete content.</p>';
					break;
				case 'd03':
					$return .= '<p class="'.$class.'">Sorry, you can only delete your own story.</p>';
					break;
				case 'f01':
					$return .= '<p class="'.$class.'">You must be logged in to be able to flag content. <a href="/login">Click here</a> to login or sign up.</p>';
					break;
				case 'f02':
					$return .= '<p class="'.$class.'">You do not have permission to flag content.</p>';
					break;
				case 'f03':
					$return .= '<p class="'.$class.'">You need more karma before you can flag content.</p>';
					break;
				case 'f04':
					$return .= '<p class="'.$class.'">Sorry, you can\'t flag your own story.</p>';
					break;
				case 's01':
					$return .= '<p class="'.$class.'">There was a problem with your entry. Please try again.</p>';
					break;
				case 'su01':
					$return .= '<p class="'.$class.'">That login name is already being used by someone! Please try again, with a different name.</p>';
					break;
				case 'su02':
					$return .= '<p class="'.$class.'">There was an error signing you up - the two password entries didn\'t match! Please make sure you enter the password you want identically in both password fields.</p>';
					break;
				case 'su03':
					$return .= '<p class="'.$class.'">You are currently logged in and cannot sign up.</p>';
					break;
				case 'su04':
					$return .= '<p class="'.$class.'">There was a problem with your signup. Please try again.</p>';
					break;
				case 'ue01':
					$return .= '<p class="'.$class.'">You must be logged in to be able to edit your details. <a href="/login">Click here</a> to login or sign up.</p>';
					break;
				case 'ue02':
					$return .= '<p class="'.$class.'">You are not allowed to edit your details.</p>';
					break;
				case 'ue03':
					$return .= '<p class="'.$class.'">You can only edit your own details.</p>';
					break;
				case 'ue04':
					$return .= '<p class="'.$class.'">There was a problem editing your profile. Please try again.</p>';
					break;
				case 'v01':
					$return .= '<p class="'.$class.'">You must be logged in to be able to vote. <a href="/login">Click here</a> to login or sign up.</p>';
					break;
				case 'v02':
					$return .= '<p class="'.$class.'">You are not allowed to vote.</p>';
					break;
				case 'v03':
					$return .= '<p class="'.$class.'">You have already voted on this.</p>';
					break;
				case 'v04':
					$return .= '<p class="'.$class.'">You can\'t vote on something that doesn\'t exist.</p>';
					break;
				case 'other':
					$return .= '<p class="'.$class.'">Totally unhandled error!</p>';
					break;
			}
		}
	}
	return $return;
}

function set_error($errNum) {
	bake('err', $errNum, 0);
}

function get_error() {
	$return = false;
	if (cookie_required('err')) {
		$return = cookie('err');
		bake('err', '', 0);
	}
	return $return;
}
Return current item: Noostr