flash messages, exception handling, and database error fixed