Skip to content

Commit

Permalink
http: /skus/{sku_code}: raise 404 HTTPException if SKU is not found
Browse files Browse the repository at this point in the history
We currently assert if the provided SKU number is not found, causing an
internal server error.  Raise an HTTPException with status 404 instead.
  • Loading branch information
simark authored and jgalar committed Feb 24, 2024
1 parent 46b5867 commit daefbe8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/canadiantracker/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ async def one_sku(
request: Request, sku_code: str
) -> starlette.templating._TemplateResponse:
sku = _repository.get_sku_by_code(sku_code)
assert sku
if sku is None:
raise HTTPException(status_code=404, detail="SKU not found")

product_url = sku.product.url
if product_url:
sku_url = make_sku_url(sku.code, product_url)
Expand Down

0 comments on commit daefbe8

Please sign in to comment.