Handling exceptions passed from MySQL