Tobscure\JsonApi\ErrorHandler::handle PHP Method

handle() public method

Handle the exception provided.
public handle ( Exception $e ) : Tobscure\JsonApi\Exception\Handler\ResponseBag
$e Exception
return Tobscure\JsonApi\Exception\Handler\ResponseBag
    public function handle(Exception $e)
    {
        foreach ($this->handlers as $handler) {
            if ($handler->manages($e)) {
                return $handler->handle($e);
            }
        }
        throw new RuntimeException('Exception handler for ' . get_class($e) . ' not found.');
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param Exception $e
  * @return JsonApiResponse
  */
 public function handle(Exception $e)
 {
     $response = $this->errorHandler->handle($e);
     $document = new Document();
     $document->setErrors($response->getErrors());
     return new JsonApiResponse($document, $response->getStatus());
 }
All Usage Examples Of Tobscure\JsonApi\ErrorHandler::handle