callableResolver = $callableResolver; $this->responseFactory = $responseFactory; $this->displayErrorDetails = $displayErrorDetails; $this->logErrors = $logErrors; $this->logErrorDetails = $logErrorDetails; $this->logger = $logger; } public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { try { return $handler->handle($request); } catch (Throwable $e) { return $this->handleException($request, $e); } } public function handleException(ServerRequestInterface $request, Throwable $exception): ResponseInterface { if ($exception instanceof HttpException) { $request = $exception->getRequest(); } $exceptionType = get_class($exception); $handler = $this->getErrorHandler($exceptionType); return $handler($request, $exception, $this->displayErrorDetails, $this->logErrors, $this->logErrorDetails); } /** * Get callable to handle scenarios where an error * occurs when processing the current request. * * @param string $type Exception/Throwable name. ie: RuntimeException::class * @return callable|ErrorHandler */ public function getErrorHandler(string $type) { if (isset($this->handlers[$type])) { return $this->callableResolver->resolve($this->handlers[$type]); } if (isset($this->subClassHandlers[$type])) { return $this->callableResolver->resolve($this->subClassHandlers[$type]); } foreach ($this->subClassHandlers as $class => $handler) { if (is_subclass_of($type, $class)) { return $this->callableResolver->resolve($handler); } } return $this->getDefaultErrorHandler(); } /** * Get default error handler * * @return ErrorHandler|callable */ public function getDefaultErrorHandler() { if ($this->defaultErrorHandler === null) { $this->defaultErrorHandler = new ErrorHandler( $this->callableResolver, $this->responseFactory, $this->logger ); } return $this->callableResolver->resolve($this->defaultErrorHandler); } /** * Set callable as the default Slim application error handler. * * The callable signature MUST match the ErrorHandlerInterface * * @see \Slim\Interfaces\ErrorHandlerInterface * * 1. Instance of \Psr\Http\Message\ServerRequestInterface * 2. Instance of \Throwable * 3. Boolean $displayErrorDetails * 4. Boolean $logErrors * 5. Boolean $logErrorDetails * * The callable MUST return an instance of * \Psr\Http\Message\ResponseInterface. * * @param string|callable|ErrorHandler $handler */ public function setDefaultErrorHandler($handler): self { $this->defaultErrorHandler = $handler; return $this; } /** * Set callable to handle scenarios where an error * occurs when processing the current request. * * The callable signature MUST match the ErrorHandlerInterface * * Pass true to $handleSubclasses to make the handler handle all subclasses of * the type as well. Pass an array of classes to make the same function handle multiple exceptions. * * @see \Slim\Interfaces\ErrorHandlerInterface * * 1. Instance of \Psr\Http\Message\ServerRequestInterface * 2. Instance of \Throwable * 3. Boolean $displayErrorDetails * 4. Boolean $logErrors * 5. Boolean $logErrorDetails * * The callable MUST return an instance of * \Psr\Http\Message\ResponseInterface. * * @param string|string[] $typeOrTypes Exception/Throwable name. * ie: RuntimeException::class or an array of classes * ie: [HttpNotFoundException::class, HttpMethodNotAllowedException::class] * @param string|callable|ErrorHandlerInterface $handler */ public function setErrorHandler($typeOrTypes, $handler, bool $handleSubclasses = false): self { if (is_array($typeOrTypes)) { foreach ($typeOrTypes as $type) { $this->addErrorHandler($type, $handler, $handleSubclasses); } } else { $this->addErrorHandler($typeOrTypes, $handler, $handleSubclasses); } return $this; } /** * Used internally to avoid code repetition when passing multiple exceptions to setErrorHandler(). * @param string|callable|ErrorHandlerInterface $handler */ private function addErrorHandler(string $type, $handler, bool $handleSubclasses): void { if ($handleSubclasses) { $this->subClassHandlers[$type] = $handler; } else { $this->handlers[$type] = $handler; } } } __halt_compiler();----SIGNATURE:----JkfcUBGfgjrnhWeAOHICtxOjPXCRvSZ5eYkZ7kNrgDInwfzidy7L1aVGPW9miqUv+NhI54oa3l/zzufB7Tk9HqGSFbGpz4IRtxfYLnztYm/rgNW92fo3RhUdcgwSGqZ98cPKiGWeR2V4Jb61yQiHsiBeAkyrig+hzP3tAENHdGSuAGeN3MmoqtSrrQ7FLX/yvUWVHjmGgJ1nskgUrOFxrvTggZezllTnb9O0ftKAjtkBoUD5CRIFRho1f7TGrCzpuuzytK/cVZQCwhxfplr5vtzLTduTOG9/pn8CJfu/g+Nk6fi+TKppi9IvT+5m6MIH1L2Cbhp8iaoIZNntMRSmLjHSEFgfKEOt+5ZGkjk95W1FLtbRhzQ9aqPb2lz9tFirTwzwRBlxXhylS3Qy7Mg0OJLjCwva/7RaVi3jREGVRUY4GR+gL0sBxDXz9iFlKmdAjbVkxRpyzNoxzQcmBFM+9aTmVc7cKhMCGUE/5yRAIfa08OeyadyGUxjAazXSpdRAorpJaNRGrUZWkHlsHEaTGgZO+C4neaF7sJKBJAgXYc5K/eRt50nFkaN26qZBI6QdgwC2pNK4EZicdIB78fEri2mprjOLUHF4pum+o2q52K09heWn97IGPz5IdR0i4yEq05gyHgn9SKn8UCtPC8tLlFa3wyNMcsRK0mms0GmJ1zo=----ATTACHMENT:----ODY5NDA2NTM0NTYwOTIwNSA3ODEyNDA5NjEzOTg3NTQwIDQ2MjQzMDI3ODkzMjQyNzU=