/** * Handle exception from scriptlet * * @param lang.Throwable t * @param int status * @param bool trace whether to show stacktrace * @return scriptlet.HttpScriptletResponse */ protected function fail(\lang\Throwable $t, $status, $trace) { $package = create(new \lang\XPClass(__CLASS__))->getPackage(); $errorPage = $package->providesResource('error' . $status . '.html') ? $package->getResource('error' . $status . '.html') : $package->getResource('error500.html'); $response = new \scriptlet\HttpScriptletResponse(); $response->setStatus($status); $response->setContent(str_replace('<xp:value-of select="reason"/>', $trace ? $t->toString() : $t->getMessage(), $errorPage)); return $response; }
/** * Handle exception from scriptlet * * @param scriptlet.Response $response * @param lang.Throwable $t * @param int $status * @param bool $trace whether to show stacktrace * @return scriptlet.HttpScriptletResponse */ protected function error($response, \lang\Throwable $t, $status, $trace) { $package = $this->getClass()->getPackage(); $errorPage = $package->getResource($package->providesResource('error' . $status . '.html') ? 'error' . $status . '.html' : 'error500.html'); $response->setProcessed(false); $response->setStatus($status); $response->setContent(str_replace('<xp:value-of select="reason"/>', $trace ? $t->toString() : $t->getMessage(), $errorPage)); }