Add error catch for protection against crash

try: execute database query
catch: any error and display the error message