PHP Exceptions and Errors designed to prevent your users from sharp corners. Inspired by Rust's helpful error messages.
There are already libraries like Whoops which focus on taking existing uncaught Exceptions and giving them a user interface.
Rather than take control of your entire UI output, Corner extends the base
Throwable
interface and Exception
/Error
classes and makes them more useful
even in non-UI contexts.
getHelpfulMessage()
> What exactly is going on here?
Imagine an email. Throwable::getMessage()
can be likened to the
subject line. In traditional exceptions, the closest thing you have
to a message body is getTraceAsString()
.
In Corner, the "helpful message" is meant to be a full-text explanation of the problem. ASCII art diagrams (hard-coded or generated from the source code, if applicable) are permitted.
getSnippet($before = 0, $after = 0, $traceWalk = 0)
> What was the code surrounding the exception doing?
By default, this returns the line of PHP code that triggered the exception.
You can optionally pass a number of leading and trailing lines to this method to read more text from the source code file. The third argument allows you to excerpt snippets of code from within the stack trace.
The main use case for getSnippet()
is to generate helpful error messages
for getHelpfulMessage()
.
getSupportLink()
> Where can I find help?
The intent of this method is to give the developer using your project the quickest possible path to troubleshooting and solving the problem that they're most likely facing if this Exception / Error gets thrown.
If possible, link to a specific section of your project's documentation (including page anchors, if applicable) to get the developer closer to the solution to whatever problem they're encountering.
Classes of Scott Arciszewski | > | Corner | > | Download .zip .tar.gz | > | Support forum | > | Blog | > | Latest changes |
|
|
Groups | Applications | Files |
Groups |
Language | Constructs to assist in the language control | View top rated classes |
PHP 7 | Classes using PHP 7 specific features | View top rated classes |
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.
Files |
File | Role | Description | ||
---|---|---|---|---|
src (4 files) | ||||
test (3 files) | ||||
.travis.yml | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
phpunit.xml.dist | Data | Auxiliary data | ||
psalm.xml | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files | / | src |
File | Role | Description |
---|---|---|
CornerInterface.php | Class | Class source |
CornerTrait.php | Class | Class source |
Error.php | Class | Class source |
Exception.php | Class | Class source |
Files | / | test |
File | Role | Description |
---|---|---|
BasicTest.php | Class | Class source |
FooError.php | Class | Class source |
FooException.php | Class | Class source |
Download all files: corner.tar.gz corner.zip NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
|