move error
This commit is contained in:
parent
59aba28faf
commit
f91c88cad3
|
@ -39,7 +39,9 @@ class ImapClient {
|
|||
$this->mailbox->deleteMail($mailid);
|
||||
$this->mailbox->expungeDeletedMails();
|
||||
} else {
|
||||
error(404, 'delete error: invalid username/mailid combination');
|
||||
// TODO: use return/throw instead
|
||||
@http_response_code(404);
|
||||
die('delete error: invalid username/mailid combination');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,20 +26,5 @@ $page->invoke($imapClient);
|
|||
// delete after each request
|
||||
$imapClient->delete_old_messages($config['delete_messages_older_than']);
|
||||
|
||||
/**
|
||||
* print error and stop program.
|
||||
* @param $status integer http status
|
||||
* @param $text string error text
|
||||
*/
|
||||
function error($status, $text) {
|
||||
@http_response_code($status);
|
||||
@print("{\"error\": \"$text\"}");
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
|
@ -25,6 +25,16 @@ abstract class Page {
|
|||
header("location: ?$name@$domain");
|
||||
}
|
||||
|
||||
/**
|
||||
* print error and stop program.
|
||||
* @param $status integer http status
|
||||
* @param $text string error text
|
||||
*/
|
||||
function error($status, $text) {
|
||||
@http_response_code($status);
|
||||
die("{\"error\": \"$text\"}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RedirectToAddressPage extends Page {
|
||||
|
@ -123,6 +133,6 @@ class DisplayEmailsPage extends Page {
|
|||
|
||||
class InvalidRequestPage extends Page {
|
||||
function invoke(ImapClient $imapClient) {
|
||||
error(400, "Bad Request");
|
||||
$this->error(400, "Bad Request");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user