feat: use custom error servlet to return json rather than default html#281
feat: use custom error servlet to return json rather than default html#281rithvik-doshi wants to merge 16 commits into
Conversation
tevanburen
left a comment
There was a problem hiding this comment.
Functionally: it returns json instead of html, which is better for FE to parse
| <location>/error/json</location> | ||
| </error-page> | ||
| <error-page> | ||
| <error-code>401</error-code> |
There was a problem hiding this comment.
Do you have an example where we generate a 401 tomcat default html page? I see examples for all the others
|
The comment from Thomas makes me question the scenarios that motivated this change. There are still scenarios where errors yield html, but just not the default tomcat error page mappings we had. Is that ok? Was the desired change supposed to change other html error page responses? For example: |
|
The js sdk is ok with receiving html from the BE (as in, it won't cause problems), it just isn't able to parse it. For that reason, json is preferred. I think we should attempt to send json wherever we can - If Anthony found a few places where we can also update to json, that's great. But it's also not a problem if we aren't able to be thorough. I'll take as much json as can be given, and any html leftover will still be ok |
Change the response on server-side errors to return JSON instead of the default Tomcat HTML, plus other error html pages we have defined. This allows the frontend to parse the response cleanly and program behavior based on error codes and messages.
To test - induce any of the following kinds of errors and note the response has changed to valid json: 400, 401, 403, 404, 500, any Throwable from Monolith.