Add a more fine tuned error handling for apis rather than just returning a `500` status
Add a more fine tuned error handling for apis rather than just returning a
500status