public function afterAction($bus) { $response = $bus->get("response"); $response->setResponses(array_merge($response->getResponses(), $bus->get("controller")->getAttributes())); if ($response->getStatus()->isServerError()) { $exception = Sabel_Context::getContext()->getException(); if (!is_object($exception)) { return; } $eol = (ENVIRONMENT & DEVELOPMENT) > 0 ? "<br />" : PHP_EOL; $msg = get_class($exception) . ": " . $exception->getMessage() . $eol . "At: " . date("r") . $eol . $eol . Sabel_Exception_Printer::printTrace($exception, $eol, true); if ((ENVIRONMENT & PRODUCTION) > 0) { } else { $response->setResponse("exception_message", $msg); } l(PHP_EOL . str_replace("<br />", PHP_EOL, $msg), SBL_LOG_ERR); } }
public function run(Sabel_Bus_Config $config) { foreach ($config->getProcessors() as $name => $className) { $this->addProcessor(new $className($name)); } foreach ($config->getConfigs() as $name => $className) { $this->setConfig($name, new $className()); } $this->interfaces = $config->getInterfaces(); $processorList = $this->processorList; $logging = $this->logging = $config->isLogging(); try { while ($processor = $processorList->next()) { $this->beforeEvent($processor->name); if ($logging) { l("Bus: execute " . $processor->name); } $processor->execute($this); $this->afterEvent($processor->name); } $processorList->first(); while ($processor = $processorList->next()) { if ($logging) { l("Bus: shutdown " . $processor->name); } $processor->shutdown($this); } return $this->get("result"); } catch (Exception $e) { $msg = get_class($e) . ": " . $e->getMessage() . PHP_EOL . "At: " . date("r") . PHP_EOL . PHP_EOL . Sabel_Exception_Printer::printTrace($e, PHP_EOL, true); l(PHP_EOL . $msg, SBL_LOG_ERR); if ((ENVIRONMENT & DEVELOPMENT) > 0) { echo nl2br($msg); } } }