[half_route] error handling

This commit is contained in:
Maxime Alves LIRMM@home 2021-12-14 09:01:38 +01:00
parent 7fb5e25411
commit 7c0f5717f4
1 changed files with 9 additions and 0 deletions

View File

@ -13,12 +13,21 @@ from starlette.routing import Route
from starlette.exceptions import HTTPException from starlette.exceptions import HTTPException
from .logging import logger from .logging import logger
from .lib.domain import MissingAclError, PathError, UnknownPathParameterType, \
UndefinedRoute, UndefinedFunction
class HalfRoute(Route): class HalfRoute(Route):
""" HalfRoute """ HalfRoute
""" """
def __init__(self, path, fct, params, method): def __init__(self, path, fct, params, method):
logger.info('HalfRoute creation: %s %s %s %s', 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__( super().__init__(
path, path,
HalfRoute.acl_decorator( HalfRoute.acl_decorator(