Back to CheckinCheckoutExceptionHandler 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 = 400;
    if ($e->getCode()) {
        $status = $e->getCode();
    }
    $error = ['title' => $e->getMessage()];
    return new ResponseBag($status, [$error]);
}