Zend\Expressive\ErrorMiddlewarePipe::__invoke PHP Method

__invoke() public method

This is essentially a version of the MiddlewarePipe that acts as a pipeline for solely error middleware; it's primary use case is to allow configuring arrays of error middleware as a single pipeline. Operation is identical to MiddlewarePipe, with the single exception that $next is called with the $error argument.
public __invoke ( mixed $error, Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $out ) : Psr\Http\Message\ResponseInterface
$error mixed
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$out callable
return Psr\Http\Message\ResponseInterface
    public function __invoke($error, Request $request, Response $response, callable $out)
    {
        // Decorate instances with Stratigility decorators; required to work
        // with Next implementation.
        $request = $this->decorateRequest($request);
        $response = $this->decorateResponse($response);
        $pipeline = $this->getInternalPipeline();
        $done = $out ?: new FinalHandler([], $response);
        $next = new Next($pipeline, $done);
        $result = $next($request, $response, $error);
        return $result instanceof Response ? $result : $response;
    }