1. Go to this page and download the library: Download php-enspired/exceptable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php-enspired / exceptable example snippets
use at\exceptable\ {
Error,
IsError
};
// a simple Error, just for you
enum ProcessError : int implements Error {
use IsError;
case NotReady = 1;
public const MESSAGES = [
self::NotReady->name => "{type} is not ready (status is '{status}')"
];
}
class Example {
public function __construct( public string $status ) {}
}
$example = new Example("preparing");
if ($example->status !== "ready") {
throw (ProcessError::NotReady)([
"type" => $example::class,
"status" => $example->status
]);
}