From b0094984e58ef1fb4d30f0e9a7646feeaeb505ee Mon Sep 17 00:00:00 2001 From: aterekhov Date: Thu, 18 Dec 2008 16:12:06 +0000 Subject: [PATCH] Rewrite standart Exception for just return error. Old functionality of showing statical pages was splitted for two new exceptions: StaticPageException for showing static templates and DynamicPageException for invoking Actions classes git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@30 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- classes/DynamicPageException.class.php | 16 ++++++++++++++++ classes/PageController.class.php | 12 +++++++++--- classes/StaticPageException.class.php | 18 ++++++++++++++++++ init/sys.inc.php | 2 ++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 classes/DynamicPageException.class.php create mode 100644 classes/StaticPageException.class.php diff --git a/classes/DynamicPageException.class.php b/classes/DynamicPageException.class.php new file mode 100644 index 0000000..92c24fd --- /dev/null +++ b/classes/DynamicPageException.class.php @@ -0,0 +1,16 @@ + diff --git a/classes/PageController.class.php b/classes/PageController.class.php index 371ef11..2a53901 100644 --- a/classes/PageController.class.php +++ b/classes/PageController.class.php @@ -26,12 +26,18 @@ final class PageController return $decorator->display($action); } catch (MJException $e) { return $e->terminate(); - } catch (Exception $e) { + } catch (DynamicPageException $e) { $decorator_name = DEFAULT_DECORATOR; - $action_name = DEFAULT_ACTION; - $decorator = new $decorator_name; + $action_name = $e->getMessage(); + return $decorator->display(new $action_name); + } catch (StaticPageException $e) { + $decorator_name = DEFAULT_DECORATOR; + $decorator = new $decorator_name; + $action_name = DEFAULT_ACTION; return $decorator->display(new $action_name($e->getMessage())); + } catch (Exception $e) { + return $e->getMessage(); } } } diff --git a/classes/StaticPageException.class.php b/classes/StaticPageException.class.php new file mode 100644 index 0000000..4943f9f --- /dev/null +++ b/classes/StaticPageException.class.php @@ -0,0 +1,18 @@ + diff --git a/init/sys.inc.php b/init/sys.inc.php index 95d2094..aa3ed69 100644 --- a/init/sys.inc.php +++ b/init/sys.inc.php @@ -42,6 +42,7 @@ define('STATIC_TPL_PATH', TPL_PATH.'/static'); define('DECORATOR_POSTFIX', 'Decorator'); define('MODEL_POSTFIX', 'Model'); define('ACTION_POSTFIX', 'Action'); +define('EXCEPTION_POSTFIX', 'Exception'); define('TIME_NOW', time()); @@ -77,6 +78,7 @@ function __autoload($name) switch ($type) { case $name: + case EXCEPTION_POSTFIX: require(CORE_PATH.'/'.$name.'.class.php'); break; case ACTION_POSTFIX: