Files

14 lines
295 B
Python

from collections.abc import Callable
from typing import TypeVar
from fastapi import HTTPException
T = TypeVar("T")
def call(action: Callable[[], T]) -> T:
try:
return action()
except RuntimeError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc