public function testCreateFromApiProblemException()
 {
     $apiProblem = ApiProblem::createFromScalar(404, 'Entity not found');
     $exception = new ApiProblemException($apiProblem);
     $apiProblem = ApiProblem::createFromException($exception);
     $this->assertApiProblem($apiProblem, ['title' => 'Not Found', 'status' => 404, 'detail' => 'Entity not found', 'type' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html']);
 }
Exemplo n.º 2
0
 public function __invoke($error, ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     if ($error instanceof \Exception) {
         $apiProblem = ApiProblem::createFromException($error);
         return $this->factory->createResponse($apiProblem);
     }
     return $next($error, $request, $response);
 }