mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix(FastAPI): add custom error templates for certain exceptions
Signed-off-by: Steven Guikal <void@fluix.one>
This commit is contained in:
parent
51b60f4210
commit
e126d431d7
4 changed files with 70 additions and 4 deletions
|
@ -87,11 +87,14 @@ def provides_markup(provides: Providers) -> str:
|
|||
|
||||
def get_pkg_or_base(
|
||||
name: str,
|
||||
cls: Union[models.Package, models.PackageBase] = models.PackageBase):
|
||||
cls: Union[models.Package, models.PackageBase] = models.PackageBase) \
|
||||
-> Union[models.Package, models.PackageBase]:
|
||||
""" Get a PackageBase instance by its name or raise a 404 if
|
||||
it can't be found in the database.
|
||||
|
||||
:param name: {Package,PackageBase}.Name
|
||||
:param exception: Whether to raise an HTTPException or simply return None if
|
||||
the package can't be found.
|
||||
:raises HTTPException: With status code 404 if record doesn't exist
|
||||
:return: {Package,PackageBase} instance
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue