Fix error handling in mysqli driver