API route error handling
What is the expected behaviour returning rejected promises in an API route?
I do not see any errors in the logs, and the API returns a 503 status code. I was expecting an error message and a 500 status code.
5 Replies
like-gold•4mo ago
your API route should return a response always
unwilling-turquoiseOP•4mo ago
thanks for the clarification
I wonder if a fallback behaviour would be sensible, as you don't get type checking for a unhandled rejected promise
Or at least some logging
If you point me to the relevant area, I'd be willing to create a PR
like-gold•4mo ago
what kind of fallback?
unwilling-turquoiseOP•3mo ago
if the function throws rather than return a response, fallback to a 500 error response and log the rejection error
also, in dev, include a log message that lets the user know they should always be returning a response
(as this is not enforced by the type system)
like-gold•3mo ago
can you please create a github issue with these "feature requests"? including some examples
also lease make sure you test this on the alpha branch with server routes