handle() public method

Handle the exception provided.
public handle ( Exception $e ) : Tobscure\JsonApi\Exception\Handler\ResponseBag
$e Exception
return Tobscure\JsonApi\Exception\Handler\ResponseBag
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());
 }
Ejemplo n.º 2
0
 public function test_it_should_throw_an_exception_when_no_handlers_are_present()
 {
     $this->setExpectedException('RuntimeException');
     $handler = new ErrorHandler();
     $handler->handle(new Exception());
 }