Fix consistent error excepttion code