Refactoring error handling.
Allow "terminate" value to be passed to log-message template as a parameter.