Safe error type switch

Ashamed...