Skip to content

Commit

Permalink
feat(api): Raise 'correct' status code upon lookup error
Browse files Browse the repository at this point in the history
While 404 clearly corresponds well to 'not found',
it is debatable whether we should return it, since the API
might have been used correctly in itself.
  • Loading branch information
alexpovel committed Aug 13, 2022
1 parent c772468 commit 8ae751f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ancv/web/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from datetime import timedelta
from http import HTTPStatus
from pathlib import Path
from typing import AsyncGenerator, Optional

Expand Down Expand Up @@ -138,7 +139,7 @@ async def username(self, request: web.Request) -> web.Response:
except ResumeLookupError as e:
stopwatch.stop()
log.warning(str(e))
return web.Response(text=str(e))
return web.Response(text=str(e), status=HTTPStatus.NOT_FOUND)
else:
stopwatch(segment="Templating")
try:
Expand Down

0 comments on commit 8ae751f

Please sign in to comment.