From 7c0f5717f45bae1b28ea3e3bf7509b0d2d8fd278 Mon Sep 17 00:00:00 2001 From: "Maxime Alves LIRMM@home" Date: Tue, 14 Dec 2021 09:01:38 +0100 Subject: [PATCH] [half_route] error handling --- halfapi/half_route.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/halfapi/half_route.py b/halfapi/half_route.py index 8879d3b..77314d8 100644 --- a/halfapi/half_route.py +++ b/halfapi/half_route.py @@ -13,12 +13,21 @@ from starlette.routing import Route from starlette.exceptions import HTTPException from .logging import logger +from .lib.domain import MissingAclError, PathError, UnknownPathParameterType, \ + UndefinedRoute, UndefinedFunction class HalfRoute(Route): """ HalfRoute """ def __init__(self, path, fct, params, method): logger.info('HalfRoute creation: %s %s %s %s', path, fct, params, method) + if len(params) == 0: + raise MissingAclError('[{}] {}'.format(verb, '/'.join(path))) + + if len(path) == 0: + logger.error('Empty path for [{%s}]', verb) + raise PathError() + super().__init__( path, HalfRoute.acl_decorator(