Better handling of SQL errors and other things that make XML unhappy