Added error handler

This commit is contained in:
2017-09-07 16:11:54 +07:00
parent 796148a532
commit 23622bc5a8
14 changed files with 204 additions and 56 deletions

View File

@@ -24,10 +24,7 @@ class Router
$route = preg_replace('/\{([a-z]+):([^\}]+)\}/', '(?P<\1>\2)', $route);
$route = '/^'.$route.'$/';
if ($this->routes[$route] = $params) {
return true;
}
return false;
$this->routes[$route] = $params;
}
public function match($url)
@@ -47,7 +44,6 @@ class Router
}
}
}
return false;
}
@@ -75,9 +71,7 @@ class Router
$action = $var['_method'];
} else {
// Token invalid
$flash = Session::flash('info', 'Token invalid, try again');
$error = Session::flash('info');
die($error);
throw new \Exception("Token invalid", 498);
}
unset($var['_token']);
unset($var['_method']);
@@ -92,8 +86,9 @@ class Router
}
}
}
throw new \Exception("Method not found", 400);
}
return false;
throw new \Exception("Page not found", 404);
}
private function removeQueryStringVariable($url)