Download the PHP package maduser/argon-error without Composer
On this page you can find all versions of the php package maduser/argon-error. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maduser/argon-error
More information about maduser/argon-error
Files in maduser/argon-error
Package argon-error
Short Description Exception policy and error response handling for the Argon runtime stack.
License MIT
Informations about the package argon-error
Argon Error
maduser/argon-error is the HTTP error-handling layer for Argon applications.
It turns uncaught throwables into PSR-7 responses, lets applications register
exception-specific reporting and rendering policies, and integrates with the
shared Argon runtime error-handler contract.
The package stays intentionally small:
ErrorHandlerbridges Argon runtime failures to the dispatcher/formatter stack.ExceptionDispatcherruns registered exception policies before falling back to the formatter.ExceptionFormattercreates JSON or plain-text PSR-7 responses.ErrorHandlerServiceProviderwires the package into anArgonContainer.
Installation
The formatter depends on PSR-17 response and stream factories. In a full Argon
stack those are normally provided by maduser/argon-http-message.
Service Provider
Register the provider during application boot:
The provider binds:
Maduser\Argon\Support\Contracts\ErrorHandlerInterfaceMaduser\Argon\Error\Contracts\ExceptionDispatcherInterfaceMaduser\Argon\Error\Contracts\ExceptionFormatterInterfaceMaduser\Argon\Error\Contracts\ExceptionPolicyRegistryInterface
Any service tagged as ExceptionPolicyInterface can register custom exception
reporting and rendering during container boot.
Exception Policies
Policies separate side effects from response creation:
- reporters run first for all matching exception types;
- renderers run after reporters and may return a
ResponseInterface; - a renderer returning
nulllets the dispatcher continue; - if no renderer returns a response, the formatter creates the fallback response.
Renderer selection is deterministic. More specific exception classes win before parent classes or interfaces. If two renderers are registered for the same specificity, registration order wins.
Reporter and renderer failures are logged and swallowed. Exception handling must not fail because an application callback failed.
Formatting
ExceptionFormatter uses the request Accept header:
application/jsonreturns a JSON error payload.- anything else returns
text/plain.
HTTP status resolution is deliberately conservative:
- exceptions implementing
HttpExceptionInterfacemay provide an explicit status code; - otherwise throwable codes in the
400..599range are used; - invalid or non-HTTP codes fall back to
500.
Stack traces are hidden by default. They are included only when debug mode is
enabled or the exception implements SafeToDisplayExceptionInterface.
All versions of argon-error with dependencies
maduser/argon-support Version ^1.0
psr/http-factory Version ^1.1
psr/http-message Version ^2.0
psr/log Version ^3.0