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