charm/exceptions

Various exception classes with some extra information such as HTTP Status Codes and HTTP Status Messages.

dev-master 2021-09-09 10:50 UTC

This package is auto-updated.

Last update: 2024-11-09 17:45:42 UTC


README

Various exceptions with a suggested HTTP Status Code and HTTP Status Message.

All exceptions are based on PHP internal exceptions, and HTTP Status Codes. Use https://en.wikipedia.org/wiki/List_of_HTTP_status_codes for reference.

try {
    throw new Charm\PageNotFoundError();
} catch (Charm\ExceptionInterface $e) {
    header("HTTP/1.0 ".$e->getHttpCode()." ".$e->getHttpStatus());
    die();
}