Documents approaches to error handling.
The overall strategy of the system is to capture errors in lower levels of the system and throw them up to an application layer that can actually do something useful with it. In this case, that means handling errors at the REST service layer. An error handler is used to process all exceptions by writing a stack trace to a log, sending email to a configured list of administrators, and sending either an HTTP code 401 or 500 back to the client with an appropriate error message depending upon whether it is an authentication/authorization failure or an application failure.
A sophisticated exception hierarchy is not leveraged. Instead, most lower level calls merely throw Exception with the possibility that it is an application defined "LocalException". The only difference here is that LocalExceptions are guaranteed to contain user friendly error messages and do not need a stack trace pushed to the log. These are known conditions in the application that trigger errors that do not require additional layers of auditing or tracking. An example of this is an attempt to log in with an incorrect username or password - in this case the user merely needs to be informed of the condition and admins do not need to respond.
In order to have emails sent in response to application errors, a few properties must be configured in the config.properties file.
|firstname.lastname@example.org||The "from" address of emails sent by the server|
|mail.smtp.password||**********||The user's mail server password|
The mail server host
|mail.smtp.port||587||The mail server port|
|mail.smtp.starttls.enable||true||A setting indicating that a TLS layer secures mail server communications|
A setting indicating that mail requests should be authenticated
|mail.smtp.to||The list of users who should receive email upon errors.|
NOTE: at the moment, the sending of email is specifically configured to support the IHTSDO style authenticated mail server. For simpler main redirection, some additional rewriting of this code may be required. It has not been tested with a simple mail server and leaving some of the config properties blank (though this may work).