PHP Class Dingo\Api\Exception\Handler

Inheritance: implements Dingo\Api\Contract\Debug\ExceptionHandler, implements Illuminate\Contracts\Debug\ExceptionHandler
Show file Open project: dingo/api Class Usage Examples

Protected Properties

Property Type Description
$debug boolean Indicates if we are in debug mode.
$format array Generic response format.
$handlers array Array of exception handlers.
$parentHandler Illuminate\Contracts\Debug\ExceptionHandler The parent Illuminate exception handler instance.
$replacements array User defined replacements to merge with defaults.

Public Methods

Method Description
__construct ( Illuminate\Contracts\Debug\ExceptionHandler $parentHandler, array $format, boolean $debug ) : void Create a new exception handler instance.
getHandlers ( ) : array Get the exception handlers.
handle ( Exception $exception ) : Illuminate\Http\Response Handle an exception if it has an existing handler.
register ( callable $callback ) : void Register a new exception handler.
render ( Dingo\Api\Http\Request $request, Exception $exception ) : mixed Render an exception into an HTTP response.
renderForConsole ( Symfony\Component\Console\Output\OutputInterface $output, Exception $exception ) : mixed Render an exception to the console.
report ( Exception $exception ) : void Report or log an exception.
setDebug ( boolean $debug ) : void Set the debug mode.
setErrorFormat ( array $format ) : void Set the error format array.
setReplacements ( array $replacements ) : void Set user defined replacements.

Protected Methods

Method Description
genericResponse ( Exception $exception ) : Illuminate\Http\Response Handle a generic error response if there is no handler available.
getExceptionStatusCode ( Exception $exception, integer $defaultStatusCode = 500 ) : integer Get the exception status code.
getHeaders ( Exception $exception ) : array Get the headers from the exception.
getStatusCode ( Exception $exception ) : integer Get the status code from the exception.
handlerHint ( callable $callback ) : string Get the hint for an exception handler.
newResponseArray ( ) : array Create a new response array with replacement values.
prepareReplacements ( Exception $exception ) : array Prepare the replacements array by gathering the keys and values.
recursivelyRemoveEmptyReplacements ( array $input ) : array Recursirvely remove any empty replacement values in the response array.
runningInDebugMode ( ) : boolean Determines if we are running in debug mode.

Method Details

__construct() public method

Create a new exception handler instance.
public __construct ( Illuminate\Contracts\Debug\ExceptionHandler $parentHandler, array $format, boolean $debug ) : void
$parentHandler Illuminate\Contracts\Debug\ExceptionHandler
$format array
$debug boolean
return void

genericResponse() protected method

Handle a generic error response if there is no handler available.
protected genericResponse ( Exception $exception ) : Illuminate\Http\Response
$exception Exception
return Illuminate\Http\Response

getExceptionStatusCode() protected method

Get the exception status code.
protected getExceptionStatusCode ( Exception $exception, integer $defaultStatusCode = 500 ) : integer
$exception Exception
$defaultStatusCode integer
return integer

getHandlers() public method

Get the exception handlers.
public getHandlers ( ) : array
return array

getHeaders() protected method

Get the headers from the exception.
protected getHeaders ( Exception $exception ) : array
$exception Exception
return array

getStatusCode() protected method

Get the status code from the exception.
protected getStatusCode ( Exception $exception ) : integer
$exception Exception
return integer

handle() public method

Handle an exception if it has an existing handler.
public handle ( Exception $exception ) : Illuminate\Http\Response
$exception Exception
return Illuminate\Http\Response

handlerHint() protected method

Get the hint for an exception handler.
protected handlerHint ( callable $callback ) : string
$callback callable
return string

newResponseArray() protected method

Create a new response array with replacement values.
protected newResponseArray ( ) : array
return array

prepareReplacements() protected method

Prepare the replacements array by gathering the keys and values.
protected prepareReplacements ( Exception $exception ) : array
$exception Exception
return array

recursivelyRemoveEmptyReplacements() protected method

Recursirvely remove any empty replacement values in the response array.
protected recursivelyRemoveEmptyReplacements ( array $input ) : array
$input array
return array

register() public method

Register a new exception handler.
public register ( callable $callback ) : void
$callback callable
return void

render() public method

Render an exception into an HTTP response.
public render ( Dingo\Api\Http\Request $request, Exception $exception ) : mixed
$request Dingo\Api\Http\Request
$exception Exception
return mixed

renderForConsole() public method

Render an exception to the console.
public renderForConsole ( Symfony\Component\Console\Output\OutputInterface $output, Exception $exception ) : mixed
$output Symfony\Component\Console\Output\OutputInterface
$exception Exception
return mixed

report() public method

Report or log an exception.
public report ( Exception $exception ) : void
$exception Exception
return void

runningInDebugMode() protected method

Determines if we are running in debug mode.
protected runningInDebugMode ( ) : boolean
return boolean

setDebug() public method

Set the debug mode.
public setDebug ( boolean $debug ) : void
$debug boolean
return void

setErrorFormat() public method

Set the error format array.
public setErrorFormat ( array $format ) : void
$format array
return void

setReplacements() public method

Set user defined replacements.
public setReplacements ( array $replacements ) : void
$replacements array
return void

Property Details

$debug protected property

Indicates if we are in debug mode.
protected bool $debug
return boolean

$format protected property

Generic response format.
protected array $format
return array

$handlers protected property

Array of exception handlers.
protected array $handlers
return array

$parentHandler protected property

The parent Illuminate exception handler instance.
protected ExceptionHandler,Illuminate\Contracts\Debug $parentHandler
return Illuminate\Contracts\Debug\ExceptionHandler

$replacements protected property

User defined replacements to merge with defaults.
protected array $replacements
return array