JError

Error Handling Class

abstract deprecated

This class is inspired in design and concept by patErrorManager http://www.php-tools.net

patErrorManager contributors include:

since

1.5

deprecated

4.0 Will be removed without replacement

package

Joomla.Legacy

Methods

addToStack

Method to add non-JError thrown JExceptions to the JError stack for debugging purposes

addToStack(\JException $e) : void
static deprecated
since

1.6

deprecated

4.0

Arguments

$e

\JExceptionAdd an exception to the stack.

attachHandler

Method that attaches the error handler to JError

attachHandler() : void
static deprecated
since

1.5

deprecated

4.0

see \set_error_handler

customErrorHandler

Display a message to the user

customErrorHandler(integer $level, string $msg) : void
static deprecated
since

1.5

deprecated

4.0 Throw an Exception or enqueue the message to the application, eg. \Joomla\CMS\Factory::getApplication()->enqueueMessage($msg)

Arguments

$level

integerThe error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.

$msg

stringError message, shown to user if need be.

customErrorPage

Display a custom error page and exit gracefully

customErrorPage(\JException $error) : void
static deprecated
since

1.5

deprecated

4.0 Use \Joomla\CMS\Exception\ExceptionHandler::render() instead

Arguments

$error

\JExceptionException object

detachHandler

Method that detaches the error handler from JError

detachHandler() : void
static deprecated
since

1.5

deprecated

4.0

see \restore_error_handler

getError

Method for retrieving the last exception object in the error stack

getError(boolean $unset = false) : \JException|boolean
static deprecated
since

1.5

deprecated

4.0

Arguments

$unset

booleanTrue to remove the error from the stack.

Response

\JException|booleanLast JException object in the error stack or boolean false if none exist

getErrorHandling

Method to get the current error handler settings for a specified error level.

getErrorHandling(integer $level) : array
static deprecated
since

1.5

deprecated

4.0

Arguments

$level

integerThe error level to retrieve. This can be any of PHP's own error levels, e.g. E_ALL, E_NOTICE...

Response

arrayAll error handling details

getErrors

Method for retrieving the exception stack

getErrors() : array<mixed,\JException>
static deprecated
since

1.5

deprecated

4.0

Response

array<mixed,\JException>Chronological array of errors that have been stored during script execution

handleCallback

Callback error handler

  • Send the error object to a callback method for error handling
handleCallback( &$error, array $options) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

Response

\JExceptionThe exception object

handleDie

Die error handler

  • Echos the error message to output and then dies
handleDie( &$error, array $options) : void
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

handleEcho

Echo error handler

  • Echos the error message to output
handleEcho( &$error, array $options) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

Response

\JExceptionThe exception object

handleIgnore

Ignore error handler

  • Ignores the error
handleIgnore( &$error, array $options) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

Response

\JExceptionThe exception object

handleLog

Log error handler Logs the error message to a system log file

handleLog( &$error, array $options) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

Response

\JExceptionThe exception object

handleMessage

Message error handler Enqueues the error message into the system queue

handleMessage( &$error, array $options) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

Response

\JExceptionThe exception object

handleVerbose

Verbose error handler

  • Echos the error message to output as well as related info
handleVerbose( &$error, array $options) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JError::raise()

Arguments

$error

$options

arrayHandler options

Response

\JExceptionThe exception object

isError

Method to determine if a value is an exception object.

isError(mixed $object) : boolean
static deprecated
since

1.5

deprecated

4.0

Arguments

$object

mixedObject to check.

Response

booleanTrue if argument is an exception, false otherwise.

raise

Create a new JException object given the passed arguments

raise(integer $level, string $code, string $msg, mixed $info = null, boolean $backtrace = false) : \JException
static deprecated
since

1.5

deprecated

4.0

see \JException

Arguments

$level

integerThe error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.

$code

stringThe application-internal error code for this error

$msg

stringThe error message, which may also be shown the user if need be.

$info

mixedOptional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

$backtrace

booleanAdd a stack backtrace to the exception.

Response

\JException

raiseError

Wrapper method for the raise() method with predefined error level of E_ERROR and backtrace set to true.

raiseError(string $code, string $msg, mixed $info = null) : \JException
static deprecated
since

1.5

deprecated

4.0 Just throw an Exception

see \JError::raise()

Arguments

$code

stringThe application-internal error code for this error

$msg

stringThe error message, which may also be shown the user if need be.

$info

mixedOptional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Response

\JException$error The thrown JException object

raiseNotice

Wrapper method for the {@link raise()} method with predefined error level of E_NOTICE and backtrace set to false.

raiseNotice(string $code, string $msg, mixed $info = null) : \JException
static deprecated
since

1.5

deprecated

4.0 Use \Joomla\CMS\Factory::getApplication()->enqueueMessage($msg, 'notice') when wou want to notify the UI

see \JError::raise()

Arguments

$code

stringThe application-internal error code for this error

$msg

stringThe error message, which may also be shown the user if need be.

$info

mixedOptional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Response

\JException$error The thrown JException object

raiseWarning

Wrapper method for the {@link raise()} method with predefined error level of E_WARNING and backtrace set to false.

raiseWarning(string $code, string $msg, mixed $info = null) : \JException
static deprecated
since

1.5

deprecated

4.0 Use \Joomla\CMS\Factory::getApplication()->enqueueMessage($msg, 'warning') when wou want to notify the UI

see \JError::raise()

Arguments

$code

stringThe application-internal error code for this error

$msg

stringThe error message, which may also be shown the user if need be.

$info

mixedOptional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Response

\JException$error The thrown JException object

registerErrorLevel

Method to register a new error level for handling errors

registerErrorLevel(integer $level, string $name, string $handler = 'ignore') : boolean
static deprecated

This allows you to add custom error levels to the built-in

  • E_NOTICE
  • E_WARNING
  • E_NOTICE
since

1.5

deprecated

4.0

Arguments

$level

integerError level to register

$name

stringHuman readable name for the error level

$handler

stringError handler to set for the new error level [optional]

Response

booleanTrue on success; false if the level already has been registered

renderBacktrace

Render the backtrace

renderBacktrace(\Exception $error) : string
static deprecated
since

1.6

deprecated

4.0 Use JLayoutHelper::render('joomla.error.backtrace', array('backtrace' => $error->getTrace())) instead

Arguments

$error

\ExceptionThe error

Response

stringContents of the backtrace

setErrorHandling

Method to set the way the JError will handle different error levels. Use this if you want to override the default settings.

setErrorHandling(integer $level, string $mode, mixed $options = null) : boolean|\JException
static deprecated

Error handling modes:

  • ignore
  • echo
  • verbose
  • die
  • message
  • log
  • callback

You may also set the error handling for several modes at once using PHP's bit operations. Examples:

  • E_ALL = Set the handling for all levels
  • E_ERROR | E_WARNING = Set the handling for errors and warnings
  • E_ALL ^ E_ERROR = Set the handling for all levels except errors
since

1.5

deprecated

4.0

Arguments

$level

integerThe error level for which to set the error handling

$mode

stringThe mode to use for the error handling.

$options

mixedOptional: Any options needed for the given mode.

Response

boolean|\JExceptionTrue on success or a JException object if failed.

throwError

Throw an error

throwError( &$exception) : \JException
static deprecated
since

1.6

deprecated

4.0 Just throw an Exception

see \JException

Arguments

$exception

Response

\JExceptionA reference to the handled JException object

translateErrorLevel

Translate an error level integer to a human readable string e.g. E_ERROR will be translated to 'Error'

translateErrorLevel(integer $level) : string|boolean
static deprecated
since

1.5

deprecated

4.0

Arguments

$level

integerError level to translate

Response

string|booleanHuman readable error level name or boolean false if it doesn't exist

Properties

legacy

Legacy error handling marker

static deprecated
since

1.7

deprecated

4.0

Type(s)

boolean

levels

Array of message levels

static deprecated
since

1.6

deprecated

4.0

Type(s)

array

handlers

Array of message handlers

static deprecated
since

1.6

deprecated

4.0

Type(s)

array

stack

Array containing the error stack

static deprecated
since

1.6

deprecated

4.0

Type(s)

array<mixed,\JException>