ErrorAction and InfoAction fixes, are now ManagedAction

This commit is contained in:
Mikael Nordfeldth 2016-01-14 21:28:47 +01:00
parent bc0a903bd4
commit 16088d9439
3 changed files with 10 additions and 35 deletions

View File

@ -64,27 +64,13 @@ class ClientErrorAction extends ErrorAction
{ {
parent::__construct($message, $code); parent::__construct($message, $code);
$this->default = 400; $this->default = 400;
}
// XXX: Should these error actions even be invokable via URI? if (!$this->code || $this->code < 400 || $this->code > 499) {
protected function handle()
{
parent::handle();
$this->code = $this->trimmed('code');
if (!$this->code || $code < 400 || $code > 499) {
$this->code = $this->default; $this->code = $this->default;
} }
$this->message = $this->trimmed('message');
if (!$this->message) { if (!$this->message) {
$this->message = "Client Error $this->code"; $this->message = "Client Error $this->code";
} }
$this->showPage();
} }
/** /**

View File

@ -44,7 +44,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
* @see ErrorAction * @see ErrorAction
*/ */
class InfoAction extends Action class InfoAction extends ManagedAction
{ {
var $message = null; var $message = null;

View File

@ -64,31 +64,20 @@ class ServerErrorAction extends ErrorAction
$this->default = 500; $this->default = 500;
if (!$this->code || $this->code < 500 || $this->code > 599) {
$this->code = $this->default;
}
if (!$this->message) {
$this->message = "Server Error $this->code";
}
// Server errors must be logged. // Server errors must be logged.
$log = "ServerErrorAction: $code $message"; $log = "ServerErrorAction: $code $message";
if ($ex) { if ($ex) {
$log .= "\n" . $ex->getTraceAsString(); $log .= "\n" . $ex->getTraceAsString();
} }
common_log(LOG_ERR, $log); common_log(LOG_ERR, $log);
}
// XXX: Should these error actions even be invokable via URI?
protected function handle()
{
parent::handle();
$this->code = $this->trimmed('code');
if (!$this->code || $code < 500 || $code > 599) {
$this->code = $this->default;
}
$this->message = $this->trimmed('message');
if (!$this->message) {
$this->message = "Server Error $this->code";
}
$this->showPage(); $this->showPage();
} }