-
Notifications
You must be signed in to change notification settings - Fork 1
BaseException
This class extends the built-in Exception class, and offers a number of enhancements that make debugging easier. It allows setting developer-specific error details as second parameter, which do not get displayed in the exception message, to hide cirtical application-internal information.
- display: Sends the exception's human readable details as a string to the browser.
- getDetails: Retrieves the additional developer-specific info, if available.
- getInfo: Converts the exception to a ThrowableInfo instance.
- createInfo: Converts any exception to a ThrowableInfo instance. Also see the parseThrowable global function.
- dumpTraceAsString: Prints a stack trace at the time the method is called, in text only format.
- dumpTraceAsHTML: Prints a stack trace at the time the method is called, in HTML format.
You can simply throw a BaseException, but it is recommended to create a class that extends it in your application. This way your exception class can inherit your application's namespace (if any), and is easier to differentiate.
File template:
<?php
/**
* File containing the MyException class.
* @see MyException
*/
declare(strict_types=1);
namespace MyNamespace;
/**
* Exception class for (Application Name) errors.
*/
class MyException extends \AppUtils\BaseException
{
}
New here?
Have a look at the overview for a list of all helper classes available in the package.
Table of contents
Find the current page in the collapsible "Pages" list above, and expand the page, to view a table of contents.