add api exception handler (#74)

* try to add exception handler

* improve server error test

* fix lint

* add build_uri util

* fix header file path

---------

Co-authored-by: Dmitry Afanasyev <afanasiev@litres.ru>
This commit is contained in:
Dmitry Afanasyev
2023-12-30 23:50:59 +03:00
committed by GitHub
parent d1ae7f2281
commit bf7a5520dc
10 changed files with 171 additions and 45 deletions

View File

@@ -1,3 +1,4 @@
import os
from datetime import datetime, timedelta
from functools import cache, wraps
from inspect import cleandoc
@@ -39,3 +40,9 @@ def clean_doc(cls: Any) -> str | None:
if cls.__doc__ is None:
return None
return cleandoc(cls.__doc__)
def build_uri(uri_parts: list[str]) -> str:
parts = [part.strip("/") for part in uri_parts]
uri = str(os.path.join(*parts)).strip("/")
return f"/{uri}"