use new error actions classes to display error

This commit is contained in:
Robin Millette 2009-01-23 05:57:08 +00:00 committed by Robin Millette
parent c628bbb192
commit fbd1cf4dfa
3 changed files with 4 additions and 49 deletions

View File

@ -23,60 +23,15 @@
function common_server_error($msg, $code=500) function common_server_error($msg, $code=500)
{ {
static $status = array(500 => 'Internal Server Error', $err = new ServerErrorAction($msg, $code);
501 => 'Not Implemented', $err->showPage();
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported');
if (!array_key_exists($code, $status)) {
$code = 500;
}
$status_string = $status[$code];
header('HTTP/1.1 '.$code.' '.$status_string);
header('Content-type: text/plain');
print $msg;
print "\n";
exit();
} }
// Show a user error // Show a user error
function common_user_error($msg, $code=400) function common_user_error($msg, $code=400)
{ {
static $status = array(400 => 'Bad Request', $err = new ClientErrorAction($msg, $code);
401 => 'Unauthorized', $err->showPage();
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed');
if (!array_key_exists($code, $status)) {
$code = 400;
}
$status_string = $status[$code];
header('HTTP/1.1 '.$code.' '.$status_string);
common_show_header('Error');
common_element('div', array('class' => 'error'), $msg);
common_show_footer();
} }
function common_init_locale($language=null) function common_init_locale($language=null)