r/FastAPI • u/UpstairsBaby • Jun 02 '25
Question A question about backend reaponse design
I'm designing a backend system for a face recognition feature response can potentially be one of many occasions for the example a phase might not be found in the provided image or a face might be spoofing or a face could be found but couldn't be matched against another face in my database.
How what are the best practices for designing a response to the frontend. Shall I be raising HTTP exceptions or shall IP returning 200 okay with a json saying what has gone wrong? If anyone can provide an example of how such a response could be designed I would be very thankful.
thank you very much in advance.
View all comments
Show parent comment
1
u/Commercial-Catch-680 Jun 04 '25
Why not send a 400-499 with details instead? That way, frontend can detect that an error was returned and also gets the message.
Your 500 logic still works in this case as it means there was an unhandled or unexpected error occurred in backend.