feat: Show Cookbooks from Other Households (#4452)

This commit is contained in:
Michael Genson
2024-11-05 13:57:30 -06:00
committed by GitHub
parent 8983745106
commit 87f4b23711
13 changed files with 264 additions and 55 deletions

View File

@@ -2,6 +2,7 @@ from collections.abc import Callable
from logging import Logger
from typing import Generic, TypeVar
import sqlalchemy.exc
from fastapi import HTTPException, status
from pydantic import UUID4, BaseModel
@@ -57,10 +58,16 @@ class HttpRepo(Generic[C, R, U]):
# Respond
msg = self.get_exception_message(ex)
raise HTTPException(
status.HTTP_400_BAD_REQUEST,
detail=ErrorResponse.respond(message=msg, exception=str(ex)),
)
if isinstance(ex, sqlalchemy.exc.NoResultFound):
raise HTTPException(
status.HTTP_404_NOT_FOUND,
detail=ErrorResponse.respond(message=msg, exception=str(ex)),
)
else:
raise HTTPException(
status.HTTP_400_BAD_REQUEST,
detail=ErrorResponse.respond(message=msg, exception=str(ex)),
)
def create_one(self, data: C) -> R | None:
item: R | None = None