idealogica/error-handler

Error handler based on Booboo with HTML and JSON support

1.0.14 2019-07-30 18:32 UTC

This package is auto-updated.

Last update: 2019-12-30 19:17:25 UTC


README

1. Features

  • allows to setup formatters based on the request uri
  • automatically detects cli mode and uses appropriate formatter
  • uses templates for customizable error pages
  • can detect exceptions which are not allowed to be shown and show general "server error" message instead of exact exception information

2. Installation

composer require idealogica/error-handler:~1.0.0

3. Basic example

$handler = new ErrorHandler(
    new ServerRequest('GET', new Uri('https://www.server.test/api/endpoint')),
    [
        '/api/.*' => [new JsonFormatter()],
        '.*' => [new HtmlFormatter(ViewFactory::createStringViewFactory())]
    ],
    [
        new CommandLineFormatter()
    ],
    $debugMode,
    InvalidArgumentException::class
);
$handler->register();

4. License

ErrorHandler is licensed under a MIT License.