trait InteractsWithExceptionHandling (View source)

Traits

Properties

protected ExceptionHandler|null $originalExceptionHandler

The original exception handler.

protected $except
protected $originalHandler

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.

$this
withExceptionHandling()

Restore exception handling.

$this
handleExceptions(array $exceptions)

Only handle the given exceptions via the exception handler.

$this
handleValidationExceptions()

Only handle validation exceptions via the exception handler.

$this
withoutExceptionHandling(array $except = [])

Disable exception handling for the test.

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

Create a new class instance.

void
report(Throwable $e)

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.

Details

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

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

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

protected $this withExceptionHandling()

Restore exception handling.

Return Value

$this

protected $this handleExceptions(array $exceptions)

Only handle the given exceptions via the exception handler.

Parameters

array $exceptions

Return Value

$this

protected $this handleValidationExceptions()

Only handle validation exceptions via the exception handler.

Return Value

$this

protected $this withoutExceptionHandling(array $except = [])

Disable exception handling for the test.

Parameters

array $except

Return Value

$this

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

Create a new class instance.

Parameters

ExceptionHandler $originalHandler
array $except

Return Value

void

void report(Throwable $e)

Report or log an exception.

Parameters

Throwable $e

Return Value

void

Exceptions

Exception

bool shouldReport(Throwable $e)

Determine if the exception should be reported.

Parameters

Throwable $e

Return Value

bool

Response render(Request $request, Throwable $e)

Render an exception into an HTTP response.

Parameters

Request $request
Throwable $e

Return Value

Response

Exceptions

Throwable

void renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

Parameters

OutputInterface $output
Throwable $e

Return Value

void