Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit f343726

Browse files
author
Phil Varner
committed
change get_order unreachability
1 parent 166ca23 commit f343726

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/stapi_fastapi/routers/root_router.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from fastapi import APIRouter, HTTPException, Request, status
55
from fastapi.datastructures import URL
6-
from returns.maybe import Some
6+
from returns.maybe import Maybe, Some
77
from returns.result import Failure, Success
88

99
from stapi_fastapi.backends.root_backend import RootBackend
@@ -162,6 +162,8 @@ async def get_order(self: Self, order_id: str, request: Request) -> Order:
162162
Link(href=str(request.url), rel="self", type=TYPE_GEOJSON)
163163
)
164164
return order
165+
case Failure(Maybe.empty):
166+
raise NotFoundException("Order not found")
165167
case Failure(Some(e)):
166168
logging.exception(
167169
f"An error occurred while retrieving order '{order_id}'", e
@@ -171,7 +173,7 @@ async def get_order(self: Self, order_id: str, request: Request) -> Order:
171173
detail="Error finding Order",
172174
)
173175
case _:
174-
raise NotFoundException("Order not found")
176+
raise AssertionError("Expected code to be unreachable")
175177

176178
def add_product(self: Self, product: Product) -> None:
177179
# Give the include a prefix from the product router

0 commit comments

Comments
 (0)