trait InteractsWithExceptionHandling

Traits

Properties

protected ExceptionHandler|null $originalExceptionHandler

The original exception handler.

Methods

string
firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

array
closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

handleExceptions(array $exceptions)

Only handle the given exceptions via the exception handler.

handleValidationExceptions()

Only handle validation exceptions via the exception handler.

withoutExceptionHandling(array $except = [])

Disable exception handling for the test.

__construct(ExceptionHandler $originalHandler, array $except = [])

Create a new exception handler instance.

void
report(Throwable $e, array $context = [], string|null $level = null)

Report or log an exception.

bool
shouldReport(Throwable $e)

Determine if the exception should be reported.

Response
render(Request $request, Throwable $e)

Render an exception into an HTTP response.

void
renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

bool
isReporting(Throwable $e)

Determine if a given exception is being reported.

array
buildContextForException(Throwable $e)

Create the context for an exception.

void
afterResponse(callable $callback)

Register a callback to be called after an HTTP error response is rendered.

Details

in ReflectsClosures at line 26
protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

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.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 75
protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in ReflectsClosures at line 97
protected array closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

at line 33
protected InteractsWithExceptionHandling withExceptionHandling()

Restore exception handling.

at line 51
protected InteractsWithExceptionHandling handleExceptions(array $exceptions)

Only handle the given exceptions via the exception handler.

Parameters

array $exceptions

Return Value

InteractsWithExceptionHandling

at line 59
protected InteractsWithExceptionHandling handleValidationExceptions()

Only handle validation exceptions via the exception handler.

at line 69
protected InteractsWithExceptionHandling withoutExceptionHandling(array $except = [])

Disable exception handling for the test.

Parameters

array $except

Return Value

InteractsWithExceptionHandling

at line 85
__construct(ExceptionHandler $originalHandler, array $except = [])

Create a new exception handler instance.

Parameters

ExceptionHandler $originalHandler
array $except

at line 97
void report(Throwable $e, array $context = [], string|null $level = null)

Report or log an exception.

Parameters

Throwable $e
array $context
string|null $level

Return Value

void

at line 104
bool shouldReport(Throwable $e)

Determine if the exception should be reported.

Parameters

Throwable $e

Return Value

bool

at line 114
Response render(Request $request, Throwable $e)

Render an exception into an HTTP response.

Parameters

Request $request
Throwable $e

Return Value

Response

Exceptions

Throwable

at line 136
void renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

Parameters

OutputInterface $output
Throwable $e

Return Value

void

at line 144
bool isReporting(Throwable $e)

Determine if a given exception is being reported.

Parameters

Throwable $e

Return Value

bool

at line 154
array buildContextForException(Throwable $e)

Create the context for an exception.

Parameters

Throwable $e

Return Value

array

at line 163
void afterResponse(callable $callback)

Register a callback to be called after an HTTP error response is rendered.

Parameters

callable $callback

Return Value

void