pinpoint icon indicating copy to clipboard operation
pinpoint copied to clipboard

Unify error responses in pinpoint web

Open ga-ram opened this issue 2 years ago • 0 comments

Current implementation has more than 3 types of error responses in pinpoint web, and there is no written standards on how to handle error on failed requests.

I'd like to suggest throwing ResponseStatusException(throw new ResponseStatusException(HttpStatus.xxx, "error message")) when error occurs so that Spring can make the response data in its ErrorController.

error response example:

HTTP Status Code: 500
Response:
{
  "timestamp": ...,
  "status": ...,
  "error":"...",
  "exception":"...",
  "trace":"...",
  "message":"...",
  "path":"...",
  "data": {
    "requestInfo": {"method": "...", "url": "...", "headers": {}, "parameters":{}}
  }
}

This way, there is lower chance to see white label page error since front end will handle the responses with above format even when unexpected exceptions has occurred.

ga-ram avatar Jun 27 '22 02:06 ga-ram