Back to AuthenticationFailedExceptionHandler class

Method handle

public \Tobscure\JsonApi\Exception\Handler\ResponseBag
handle
(\Exception $e)
Handle the provided exception.
Parameters
  • \Exception $e The exception being handled
Returns
  • \Tobscure\JsonApi\Exception\Handler\ResponseBag
Since
  • 4.0.0

Method handle - Source code

/**
 * Handle the provided exception.
 *
 * @param   Exception  $e  The exception being handled
 *
 * @return  \Tobscure\JsonApi\Exception\Handler\ResponseBag
 *
 * @since  4.0.0
 */
public function handle(Exception $e)
{
    $status = 401;
    $error = ['title' => 'Forbidden'];
    $code = $e->getCode();
    if ($code) {
        $error['code'] = $code;
    }
    return new ResponseBag($status, [$error]);
}