better mysql error handling