2
0
mirror of https://github.com/boostorg/website.git synced 2026-02-24 16:32:16 +00:00

Adjust a lot of the error handling.

Use exceptions for most internal errors. Return error codes for most errors.
This commit is contained in:
Daniel James
2016-09-29 02:08:52 +01:00
parent f4472fc751
commit b8120cc53c
15 changed files with 57 additions and 57 deletions

View File

@@ -8,6 +8,7 @@ require_once(__DIR__.'/../common/code/bootstrap.php');
function main($args) {
if (!array_key_exists('page', $args)) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Missing page argument', true, 400);
echo "Missing page argument.\n";
exit(1);
}
@@ -18,6 +19,7 @@ function main($args) {
$page->display();
break;
default:
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Page not found', true, 404);
echo "Unknown page: ", htmlentities($args['page']), "\n";
exit(1);
}

View File

@@ -1,12 +1,13 @@
<?php
require_once(__DIR__.'/../common/code/boost.php');
require_once(__DIR__.'/../common/code/bootstrap.php');
if (isset($_GET['version'])) {
try {
$version = BoostVersion::from($_GET['version']);
}
catch (BoostVersion_Exception $e) {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
echo json_encode(Array(
'error' => $e->getMessage(),
));

View File

@@ -53,7 +53,7 @@ class LibraryPage {
$filter_value = '';
if (!preg_match('@^[-_a-zA-Z0-9]+$@', $view_value)) {
die('Invalid view value.');
throw new BoostException('Invalid view value.');
}
if (strpos($view_value, 'filtered_') === 0) {