Add error handling to authentication and stack trace option to DB exceptions.