Installable via Composer as bdk/errorhandler
{
"require": {
"bdk/debug": "^2.0"
}
}
__construct(EventManager $eventManager[, array $cfg = array()])
Constructor
errorReporting(): int
What error level are we handling
get(string $key[, string $hash = null]): mixed
Retrieve a data value or property
static getInstance(array $cfg = array()): object|false
Returns the Singleton instance of this class (IF INSTANCE EXISTS)
getLastError(bool $inclSuppressed = false): Error|null
Get information about last error
handleError(int $errType, string $errMsg, string $file, int $line[, array $vars = array()]): bool
Error handler
handleException(Exception|Throwable $exception)
Handle uncaught exceptions
This isn't strictly necessary... uncaught exceptions are a fatal error, which we can handle... However:
onShutdown(Event $event)
EventManager::EVENT_PHP_SHUTDOWN event subscriber
Used to handle fatal errors
Test fatal error handling by publishing EventManager::EVENT_PHP_SHUTDOWN event with error value
register()
Register this error handler and shutdown function
setErrorCaller(array|null|false $caller = null[, int $offset = 0])
Set the calling file/line for next error.
This override will apply until cleared or error occurs
Example: some wrapper function that is called often: Rather than reporting that an error occurred within the wrapper, you can use setErrorCaller() to report the error originating from the file/line that called the function
unregister()
Un-register this error handler
Restores previous error handler
setData(string $key, mixed $value)
Set data value
__get(string $prop): mixed
Magic getter
Get inaccessible / undefined properties Lazy load child classes
__isset(string $prop): bool
Magic isset
__set(string $prop, mixed $value)
Magic setter
getCfg(array|string $path = null): mixed
Retrieve a configuration value
setCfg(array|string $mixed[, mixed $val = null]): mixed
Set one or more config values
setCfg('key', 'value')
setCfg(array('k1'=>'v1', 'k2'=>'v2'))
Calls self::postSetCfg() with new values and previous values
__construct(ErrorHandler $errHandler, array $values)
Constructor
asException(): Exception|ErrorException
Return as ErrorException (or caught exception)
If error is an uncaught exception, the original Exception will be returned
getBacktrace(bool|auto $withContext = auto): array|false|null
Alias for `getTrace()
getContext(): array|false
Get php code surrounding error
getFileAndLine(): string
Get file and line string
getMessage(): string
Get error message
getMessageHtml(): string
Get the message html-escaped
getMessageText(): string
Get the plain text error message (html tags removed)
getTrace(bool|auto $withContext = auto): array|false|null
Get backtrace
Backtrace is avail for fatal errors (incl uncaught exceptions) (does not include parse errors)
log(): bool
Send error to error_log()
offsetGet(TKey $key): TValue|null
ArrayAccess
getValue.
isFatal(): bool
Is this error "fatal"?
setValues(array<TKey,TValue> $values = array()): $this
Clears existing values and sets new values
static typeStr(int $type): string
Get human-friendly error type
__debugInfo(): array{
propagationStopped: bool,
subject: class-string|mixed,
values: array<TKey, TValue>,
}
Magic Method
getSubject(): ErrorHandler
Get Error's subject (ErrorHandler
instance)
isPropagationStopped(): bool
Has propagation been stopped?
If stopped, no further event subscribers will be called
stopPropagation()
Stops the propagation of the error event
No further event subscribers will be called
__serialize(): array<TKey,TValue>
Serialize magic method (since php 7.4)
__unserialize(array<TKey,TValue> $data)
Unserialize
getIterator(): ArrayIterator<TKey,TValue>
IteratorAggregate
interface
Iterate over the object like an array.
getValue(TKey $key): TValue|null
Get value by key.
getValues(): array<TKey,TValue>
Get all stored values
hasValue(TKey $key): bool
Does specified key have a value?
jsonSerialize(): array<TKey,TValue>
Implements JsonSerializable
offsetExists(TKey $key): bool
ArrayAccess
hasValue.
offsetSet(TKey $offset, TValue $value)
ArrayAccess
setValue
offsetUnset(TKey $key)
ArrayAccess
interface
serialize(): string
Implements Serializable
setValue(TKey $key, TValue $value): $this
Set error value
unserialize(string $data)
Implements Serializable