]> git.andy128k.dev Git - ipf.git/commitdiff
response via exception trap
authorAndrey Kutejko <andy128k@gmail.com>
Sun, 24 Aug 2014 16:05:36 +0000 (19:05 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sun, 24 Aug 2014 16:05:36 +0000 (19:05 +0300)
ipf/http/error404.php [deleted file]
ipf/router.php

diff --git a/ipf/http/error404.php b/ipf/http/error404.php
deleted file mode 100644 (file)
index a6b1a9b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<?php
-
-class IPF_HTTP_Error404 extends IPF_Exception
-{
-}
-
index 91dc75f97feb1c222a4c62a0dc486ca7d641f515..70bfb2bc80471f739bd824fb375461bacfcd9ad0 100644 (file)
@@ -91,8 +91,8 @@ class IPF_Router
                     return self::response500($req, new IPF_Exception('function '.$func.'() must return IPF_HTTP_Response instance'));
                 }
                 return $r;
-            } catch (IPF_HTTP_Error404 $e) {
-                return new IPF_HTTP_Response_NotFound($req);
+            } catch (IPF_Router_Shortcut $e) {
+                return $e->response($req);
             } catch (IPF_Exception $e) {
                 return self::response500($req, $e);
             }
@@ -201,3 +201,16 @@ class IPF_Route
     }
 }
 
+abstract class IPF_Router_Shortcut extends Exception
+{
+    public abstract function response($request);
+}
+
+class IPF_HTTP_Error404 extends IPF_Router_Shortcut
+{
+    public function response($request)
+    {
+        return new IPF_HTTP_Response_NotFound($request);
+    }
+}
+