api - How to show the internal server errors to the user? -
i working in api . want throw detailed error messages user. in situation decide kind of error code should sent or how explain user if error occurs in application internally. example if database connection fails , kind of http status code want send user ?
can ?
an http status code refers status of http request itself, not status of application handling request. therefore, server-side errors covered 500 internal server error. additional info error should described in response body. apis, response body json or xml, can use formats errors. this:
http/1.1 500 internal server error [headers] {"status":"error", "message":"the request failed due database connectivity."}
there are, however, 2 cases can think of when might want status code. if user has requested api method not implemented, might want 501 not implemented, , when there temporary service outage, can use 503 service unavailable.
more info server-side status codes here.
Comments
Post a Comment