handle SQL errors in app