- System Errors
- eg null pointers/failed db query/failed api calls
- Log this at the error level
- Log stack trace if possible
- Log any relevant identifiers if possible
- Don't log any unapproved sensitive data
- User errors
- eg invalid zip code/name length
- Optionally log at warn level
- Still an error for the user just not the system
- Notify user of the error
- Use Alerts, Toast, HTTP Codes/Payload, Kaka Message
- Clearly define the specific issue
- eg invalid last name is better than invalid request
- eg last name too long is better than invalid last name
- eg last name must be less than 25 characters better than last name too long
- If it makes sense describe ways to correct issue
- eg if database is locked ask user to retry later
- Clearly define the specific issue
- Use Alerts, Toast, HTTP Codes/Payload, Kaka Message
- Do not throw an exception if it can be handled in the current function
- Catch user error exceptions so they don't trigger error messages
- Do clean up regardless of exception in finally block
- Use framework exception handling where applicable (eg. @ControllerAdvice)