From 4942af27dc51fdba4fbcf2e5c3190022e351feb1 Mon Sep 17 00:00:00 2001 From: Yun Xu Date: Fri, 9 Jun 2017 08:33:34 -0700 Subject: [PATCH] handle NotFound --- sanic/router.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sanic/router.py b/sanic/router.py index 2581e178..f379b095 100644 --- a/sanic/router.py +++ b/sanic/router.py @@ -351,7 +351,10 @@ class Router: :param request: Request object :return: bool """ - handler = self.get(request)[0] + try: + handler = self.get(request)[0] + except NotFound: + return False if (hasattr(handler, 'view_class') and hasattr(handler.view_class, request.method.lower())): handler = getattr(handler.view_class, request.method.lower())