process() public method

Adds an error handler that will convert PHP errors to ErrorException instances. Internally, wraps the call to $next() in a try/catch block, catching all PHP Throwables (PHP 7) and Exceptions (PHP 5.6 and earlier). When an exception is caught, an appropriate error response is created and returned instead; otherwise, the response returned by $next is used.
public process ( Psr\Http\Message\ServerRequestInterface $request, Interop\Http\Middleware\DelegateInterface $delegate ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$delegate Interop\Http\Middleware\DelegateInterface
return Psr\Http\Message\ResponseInterface
 public function testCanProvideAlternateErrorResponseGenerator()
 {
     $generator = function ($e, $request, $response) {
         $response = $response->withStatus(400);
         $response->getBody()->write('The client messed up');
         return $response;
     };
     $this->delegate->process(Argument::type(ServerRequestInterface::class))->willThrow(new RuntimeException('Exception raised', 503));
     $this->response->withStatus(400)->will([$this->response, 'reveal']);
     $this->response->getBody()->will([$this->body, 'reveal']);
     $this->body->write('The client messed up')->shouldBeCalled();
     $middleware = new ErrorHandler($this->response->reveal(), $generator);
     $result = $middleware->process($this->request->reveal(), $this->delegate->reveal());
     $this->assertSame($this->response->reveal(), $result);
 }