add checking for error states

Just checking for global.errors is no longer enough.