fix error handling of 401 response