Handler
class Handler extends Handler
| internal |
Traits
Constants
| REPORTED_EXCEPTION_MAP_CONTEXT_KEY |
Context key for the per-request reported exception deduplication map. |
| AFTER_RESPONSE_CONTEXT_KEY |
Context key for after-response callbacks. |
| CURRENTLY_REPORTING_CONTEXT_KEY |
Context key for the exception currently being reported. |
Properties
| protected Throwable>> | $dontReport | A list of the exception types that are not reported. |
from Handler |
| protected ReportableHandler[] | $reportCallbacks | The callbacks that should be used during reporting. |
from Handler |
| protected array | $contextCallbacks | The callbacks that should be used to build exception context data. |
from Handler |
| protected Closure[] | $dontReportCallbacks | The callbacks that should be used to determine if an exception should not be reported. |
from Handler |
| protected Throwable>> | $dontRetry | A list of the exception types that should stop job retries. |
from Handler |
| protected Closure> | $dontRetryCallbacks | The callbacks that inspect exceptions to determine if they should stop job retries. |
from Handler |
| protected Closure[] | $throttleCallbacks | The callbacks that should be used to throttle reportable exceptions. |
from Handler |
| protected Closure[] | $renderCallbacks | The callbacks that should be used during rendering. |
from Handler |
| protected null|callable | $shouldRenderJsonWhenCallback | The callback that determines if the exception handler response should be JSON. |
from Handler |
| protected null|callable | $finalizeResponseCallback | The callback that prepares responses to be returned to the browser. |
from Handler |
| protected Closure> | $exceptionMap | The registered exception mappings. |
from Handler |
| protected LogLevel::*> | $levels | A map of exceptions with their corresponding custom log levels. |
from Handler |
| protected RequestExceptionInterface>|Throwable>> | $internalDontReport | A list of the internal exception types that should not be reported. |
from Handler |
| protected array<int, string> | $dontFlash | A list of the inputs that are never flashed for validation exceptions. |
from Handler |
| protected bool | $withoutDuplicates | Indicate that an exception instance should only be reported once. |
from Handler |
Methods
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Get the class names / types of the return type of the given Closure.
Indicate that the given exception type should not be reported.
Register a callback to determine if an exception should not be reported.
Indicate that the given exception type should not be reported.
Indicate that jobs should stop retrying for the given exception types.
Register a callback to determine if jobs should stop retrying for an exception.
Indicate that the given attributes should never be flashed to the session on validation errors.
Report error based on report method on exception or to logger.
Run the callback while the given exception is marked as being reported by this coroutine.
Specify the callback that should be used to throttle reportable exceptions.
Remove the given exception class from the list of exceptions that should be ignored.
Create the context array for logging the given exception.
Register a closure that should be used to build exception context data.
Prepare the final, rendered response to be returned to the browser.
Register a callback to be called after an HTTP error response is rendered.
Get the callbacks that should be called after an HTTP error response is rendered.
Prepare the final, rendered response for an exception using the given callback.
Try to render a response from request and exception via render callbacks.
Convert an authentication exception into a response.
Create a response object from the given validation exception.
Convert a validation exception into a response.
Convert a validation exception into a JSON response.
Determine if the exception handler response should be JSON.
Register the callable that determines if the exception handler response should be JSON.
Render an exception to a string using the registered ExceptionRenderer.
Render an exception to a string using Symfony.
Render the given HttpException.
Get the view used to render HTTP exceptions.
Map the given exception into a Hypervel response.
Prepare a JSON response for the given exception.
Details
in
ReflectsClosures at line 26
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
in
ReflectsClosures at line 49
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
in
ReflectsClosures at line 75
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
in
ReflectsClosures at line 97
protected array
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
in
Handler at line 219
void
register()
Register the exception handling callbacks for the application.
in
Handler at line 232
ReportableHandler
reportable(callable $reportUsing)
Register a reportable callback.
The callback receives exceptions matching its first parameter type, along with the exception's log context. Returning false stops further reporting.
Boot-only. The callback persists on the shared handler and affects exception reporting for every subsequent request and job in the worker.
in
Handler at line 249
Handler
renderable(callable $renderUsing)
Register a renderable callback.
Boot-only. The callback persists on the shared handler and affects exception rendering for every subsequent request in the worker.
in
Handler at line 268
Handler
map(callable|string $from, Closure|string|null $to = null)
Register a new exception mapping.
Boot-only. The mapping persists on the shared handler and affects exception reporting and rendering for every subsequent request and job in the worker.
in
Handler at line 295
Handler
dontReport(array|string $exceptions)
Indicate that the given exception type should not be reported.
Alias of "ignore".
Boot-only. The exception types persist on the shared handler and affect exception reporting for every subsequent request and job in the worker.
in
Handler at line 308
Handler
dontReportWhen(callable $dontReportWhen)
Register a callback to determine if an exception should not be reported.
Boot-only. The callback persists on the shared handler and affects exception reporting for every subsequent request and job in the worker.
in
Handler at line 325
Handler
ignore(array|string $exceptions)
Indicate that the given exception type should not be reported.
Boot-only. The exception types persist on the shared handler and affect exception reporting for every subsequent request and job in the worker.
in
Handler at line 340
Handler
dontRetry(array|string $exceptions)
Indicate that jobs should stop retrying for the given exception types.
Boot-only. The exception types persist on the shared handler and affect every subsequently failed job in the worker.
in
Handler at line 359
Handler
dontRetryWhen(callable $dontRetryWhen)
Register a callback to determine if jobs should stop retrying for an exception.
Boot-only. The callback persists on the shared handler and affects job retry decisions for every subsequent job in the worker.
in
Handler at line 373
bool
shouldStopRetries(Throwable $e)
Determine if jobs should stop retrying for the given exception.
in
Handler at line 433
Handler
dontFlash(array|string $attributes)
Indicate that the given attributes should never be flashed to the session on validation errors.
Boot-only. The attributes persist on the shared handler and are omitted from every subsequent validation redirect in the worker.
in
Handler at line 451
Handler
level(string $type, string $level)
Set the log level for the given exception type.
Boot-only. The level persists on the shared handler and affects how later exceptions of that type are logged in the worker.
in
Handler at line 466
void
report(Throwable $e, array $context = [], string|null $level = null)
Report or log an exception.
in
Handler at line 490
protected void
reportThrowable(Throwable $e, array $context = [], string|null $level = null)
Report error based on report method on exception or to logger.
in
Handler at line 537
protected mixed
whileReporting(Throwable $e, Closure $callback)
Run the callback while the given exception is marked as being reported by this coroutine.
in
Handler at line 559
bool
isReporting(Throwable $e)
Determine if the given exception is being reported by this coroutine.
in
Handler at line 571
protected void
reportedException(Throwable $e)
Mark the given exception as reported.
in
Handler at line 579
protected bool
hasReportedException(Throwable $e)
Determine if the given exception has already been reported.
in
Handler at line 587
protected WeakMap
reportedExceptionMap()
Get the reported exception map for the current request.
in
Handler at line 602
bool
shouldReport(Throwable $e)
Determine if the exception should be reported.
in
Handler at line 610
protected bool
shouldntReport(Throwable $e)
Determine if the exception is in the "do not report" list.
in
Handler at line 659
protected Lottery|AdmissionPolicy|null
throttle(Throwable $e)
Throttle the given exception.
in
Handler at line 682
Handler
throttleUsing(callable $throttleUsing)
Specify the callback that should be used to throttle reportable exceptions.
Boot-only. The callback persists on the shared handler and affects exception reporting for every subsequent request and job in the worker.
in
Handler at line 699
Handler
stopIgnoring(array|string $exceptions)
Remove the given exception class from the list of exceptions that should be ignored.
Boot-only. The exception lists persist on the shared handler and affect exception reporting for every subsequent request and job in the worker.
in
Handler at line 719
array
contextForException(Throwable $e)
Create the context array for logging the given exception.
in
Handler at line 729
protected array
buildExceptionContext(Throwable $e, array $context = [])
Create the context array for logging the given exception.
in
Handler at line 744
array
buildContextForException(Throwable $e)
Create the context for the given exception.
in
Handler at line 752
protected array
exceptionContext(Throwable $e)
Get the default exception context variables for logging.
in
Handler at line 770
protected array
context()
Get the default context variables for logging.
in
Handler at line 791
Handler
buildContextUsing(Closure $contextCallback)
Register a closure that should be used to build exception context data.
Boot-only. The closure persists on the shared handler and runs for every subsequently logged exception in the worker.
in
Handler at line 803
Response
render(Request $request, Throwable $e)
Render an exception into an HTTP response.
in
Handler at line 840
protected Response
finalizeRenderedResponse(Request $request, Response $response, Throwable $e)
Prepare the final, rendered response to be returned to the browser.
in
Handler at line 858
void
afterResponse(callable $callback)
Register a callback to be called after an HTTP error response is rendered.
in
Handler at line 871
protected array
afterResponseCallbacks()
Get the callbacks that should be called after an HTTP error response is rendered.
in
Handler at line 882
Handler
respondUsing(callable $callback)
Prepare the final, rendered response for an exception using the given callback.
Boot-only. The callback replaces the shared handler's response callback for every subsequent request in the worker.
in
Handler at line 892
protected Throwable
prepareException(Throwable $e)
Prepare exception for rendering.
in
Handler at line 915
protected Throwable
mapException(Throwable $e)
Map the exception using a registered mapper if possible.
in
Handler at line 935
protected Response|null
renderViaCallbacks(Request $request, Throwable $e)
Try to render a response from request and exception via render callbacks.
in
Handler at line 953
protected Response|JsonResponse|RedirectResponse
renderExceptionResponse(Request $request, Throwable $e)
Render a default exception response if any.
in
Handler at line 963
protected Response|JsonResponse|RedirectResponse
unauthenticated(Request $request, AuthenticationException $exception)
Convert an authentication exception into a response.
in
Handler at line 981
protected Response
convertValidationExceptionToResponse(ValidationException $e, Request $request)
Create a response object from the given validation exception.
in
Handler at line 995
protected RedirectResponse
invalid(Request $request, ValidationException $exception)
Convert a validation exception into a response.
in
Handler at line 1010
protected JsonResponse
invalidJson(Request $request, ValidationException $exception)
Convert a validation exception into a JSON response.
in
Handler at line 1021
protected bool
shouldReturnJson(Request $request, Throwable $e)
Determine if the exception handler response should be JSON.
in
Handler at line 1036
Handler
shouldRenderJsonWhen(callable $callback)
Register the callable that determines if the exception handler response should be JSON.
Boot-only. The callable replaces the shared handler's JSON check for every subsequent request in the worker.
in
Handler at line 1046
protected Response|RedirectResponse
prepareResponse(Request $request, Throwable $e)
Prepare a response for the given exception.
in
Handler at line 1065
protected Response
convertExceptionToResponse(Throwable $e)
Create a Symfony response for the given exception.
in
Handler at line 1077
protected string
renderExceptionContent(Throwable $e)
Get the response content for the given exception.
in
Handler at line 1100
protected string
renderExceptionWithCustomRenderer(Throwable $e)
Render an exception to a string using the registered ExceptionRenderer.
in
Handler at line 1108
protected string
renderExceptionWithSymfony(Throwable $e, bool $debug)
Render an exception to a string using Symfony.
in
Handler at line 1120
protected Response
renderHttpException(HttpExceptionInterface $e)
Render the given HttpException.
in
Handler at line 1150
protected void
registerErrorViewPaths()
Register the error template hint paths.
in
Handler at line 1158
protected string|null
getHttpExceptionView(HttpExceptionInterface $e)
Get the view used to render HTTP exceptions.
in
Handler at line 1178
protected Response|RedirectResponse
toHypervelResponse(Response $response, Throwable $e)
Map the given exception into a Hypervel response.
in
Handler at line 1200
protected JsonResponse
prepareJsonResponse(Request $request, Throwable $e)
Prepare a JSON response for the given exception.
in
Handler at line 1213
protected array
convertExceptionToArray(Throwable $e)
Convert the given exception to an array.
in
Handler at line 1229
void
renderForConsole(OutputInterface $output, Throwable $e)
Render an exception to the console.
in
Handler at line 1261
Handler
dontReportDuplicates()
Do not report duplicate exceptions.
Boot-only. The setting persists on the shared handler and applies to every subsequent request and job in the worker.
in
Handler at line 1273
protected bool
isHttpException(Throwable $e)
Determine if the given exception is an HTTP exception.
in
Handler at line 1283
protected string
mapLogLevel(Throwable $e)
Map the exception to a log level.
in
Handler at line 1295
protected LoggerInterface
newLogger()
Create a new logger instance.