jeremy303
jeremy303

Reputation: 9241

Best practice for reporting Internal Service Error 500 for RESTful web service?

I'm looking for best practices for reporting internal service errors (status code 500) when something unexpected goes wrong with my RESTful web service.

I'm not referring to conditions covered by other status codes, but for truly exceptional, unexpected errors internal to my application.

Displaying detailed error information such as exception details could benefit debugging, but this would expose internal details of my server. This seems like a Bad Thing (tm).

Perhaps it's best to just report a high, level error message with a time stamp? Error details should of course be in the server log.

Any good examples out there for inspiration?

Upvotes: 2

Views: 748

Answers (1)

abraham
abraham

Reputation: 47833

Don't show detailed debug info externally. A good approach is to create a unique hash/id of the error event and surface that. Ideally that id can be used on your end to look up additional details. Here is an example of how YouTube does it. They go a bit crazy on the length however.

Upvotes: 3

Related Questions