diff --git a/README.md b/README.md index cc3666e..3a50b96 100644 --- a/README.md +++ b/README.md @@ -1036,6 +1036,17 @@ class CustomExceptionHandler implements IExceptionHandler return; } + + /* Other error */ + if($error instanceof MyCustomException) { + + $request->setRewriteRoute( + // Add new route based on current url (minus query-string) and add custom parameters. + (new RouteUrl(url(null, null, []), 'PageController@error'))->setParameters(['exception' => $error]) + ); + return; + + } throw $error; diff --git a/src/Pecee/SimpleRouter/Router.php b/src/Pecee/SimpleRouter/Router.php index a066b77..c00c8d5 100644 --- a/src/Pecee/SimpleRouter/Router.php +++ b/src/Pecee/SimpleRouter/Router.php @@ -346,7 +346,7 @@ class Router /* Verify csrf token for request */ $this->csrfVerifier->handle($this->request); } catch(Exception $e) { - $this->handleException($e); + return $this->handleException($e); } } @@ -444,12 +444,12 @@ class Router } } catch (Exception $e) { - $this->handleException($e); + return $this->handleException($e); } if ($methodNotAllowed === true) { $message = sprintf('Route "%s" or method "%s" not allowed.', $this->request->getUrl()->getPath(), $this->request->getMethod()); - $this->handleException(new NotFoundHttpException($message, 403)); + return $this->handleException(new NotFoundHttpException($message, 403)); } if (count($this->request->getLoadedRoutes()) === 0) {