public function execute(Request $request, Response $response) { parent::execute($request, $response); Logger::info("Starting processing of listener request from {$this->request->getClientIp()}"); try { $this->doIngressSecurity(); $msgs = $this->parseEnvelope($request); if (is_array($msgs)) { foreach ($msgs as $msg) { $this->processMessage($msg); } } $this->ackEnvelope(); } catch (ListenerSecurityException $ex) { Logger::notice('Message denied by security policy, death is me.', null, $ex); $response->setStatusCode(403, "Not authorized."); } catch (ListenerDataException $ex) { Logger::error('Listener received request it could not process, death is me.', null, $ex); $response->setStatusCode(500, 'Received data could not be processed.'); } catch (Core\ConfigurationException $ex) { Logger::alert('Some sad panda gave me a bad configuration.', null, $ex); $response->setStatusCode(500, "Configuration error."); } catch (\Exception $ex) { Logger::error('Listener threw an unknown exception, death is me.', null, $ex); $response->setStatusCode(500, "Unknown listener exception"); } Logger::info('Finished processing listener request'); }
/** * Hook from set_exception_handler(). Will clear output data, set the HTTP status to 500: Internal Error * and then die. * * @param \Exception $ex The uncaught exception */ public static function lastChanceExceptionHandler($ex) { Logger::alert("Last chance exception handler fired.", null, $ex); $response = new Response(); $response->setPrivate(); $response->setStatusCode(500, "Unhandled internal server exception."); $response->send(); }
/** * Hook from set_exception_handler(). Will clear output data, set the HTTP * status to 500: Internal Error and then die. * * @param \Exception $ex The uncaught exception */ public static function lastChanceExceptionHandler($ex) { MaintenanceBase::error("{$ex->getMessage()} @ {$ex->getFile()}:{$ex->getLine()}.\n{$ex->getTraceAsString()}", true); Logger::alert("Last chance exception handler fired.", null, $ex); }