diff --git a/application/classes/Kohana/Exception.php b/application/classes/Kohana/Exception.php new file mode 100644 index 00000000..6354d239 --- /dev/null +++ b/application/classes/Kohana/Exception.php @@ -0,0 +1,65 @@ +message = Kohana_Exception::text($e); + $eo->account_id = Auth::instance()->get_user()->id; + $eo->module = (Request::current()->directory() ? Request::current()->directory().'_' : '').Request::current()->controller(); + $eo->method = Request::current()->action(); + $eo->save(); + + } catch (Exception $x) { + return parent::log($e,$level); + } + } + + /** + * Redirect errors to the main page after showing a system message. + * The error should be logged in the DB. + * + * @param Exception $e + * @return Response + */ + public static function response(Exception $e) { + try { + if (Kohana::$config->load('debug')->show_errors) { + return parent::response($e); + } else { + SystemMessage::add(array( + 'title'=>'An Error Occured.', + 'type'=>'error', + 'body'=>'A error occured, which has been logged.', + )); + + + // We'll redirect to the main page. + $response = Response::factory(); + $response->status(302); + $response->headers('Location',URL::site()); + return $response; + } + + } catch (Exception $x) { + return parent::response($e); + } + } +} +?> diff --git a/application/classes/Model/Log/Error.php b/application/classes/Model/Log/Error.php new file mode 100644 index 00000000..357fb856 --- /dev/null +++ b/application/classes/Model/Log/Error.php @@ -0,0 +1,14 @@ + diff --git a/application/config/debug.php b/application/config/debug.php index 77608137..9fedb4e4 100644 --- a/application/config/debug.php +++ b/application/config/debug.php @@ -18,6 +18,7 @@ return array 'checkout_notify'=>FALSE, // Test mode to test a particular checkout_notify item 'invoice'=>0, // Number of invoices to generate in a pass 'site'=>FALSE, // Glogal site debug + 'show_errors'=>FALSE, // Show errors instead of logging in the DB. 'show_inactive'=>FALSE, // Show Inactive Items 'task_sim'=>FALSE, // Simulate running tasks );