From dc4e075f3f6e02586b03f931cb3f443d80aac74b Mon Sep 17 00:00:00 2001 From: shoully Date: Sat, 20 Dec 2014 06:01:52 -0800 Subject: [PATCH] Created Error Handling (markdown) --- Error-Handling.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Error-Handling.md diff --git a/Error-Handling.md b/Error-Handling.md new file mode 100644 index 0000000..618dd6f --- /dev/null +++ b/Error-Handling.md @@ -0,0 +1,28 @@ +## Errors and Exceptions + +All errors and exceptions are caught by Flight and passed to the `error` method. +The default behavior is to send a generic HTTP `500 Internal Server Error` response with some error information. +You can override this behavior for your own needs: + + Flight::map('error', function(){ + // Handle error + }); + +By default errors are not logged to the web server. You can enable this by changing the config: + + Flight::set('flight.log_errors', true); + +## Not Found + +When a URL can't be found, Flight calls the `notFound` method. The default behavior is to +send an HTTP `404 Not Found` response with a simple message. You can override this behavior for your own needs: + + Flight::map('notFound', function(){ + // Handle not found + }); + +# Redirects + +You can redirect the current request by using the `redirect` method and passing in a new URL: + + Flight::redirect('/new/location'); \ No newline at end of file