Adding generic error handling. All errors are caught and logged to file, 500 returned.