I think the code throwing this exception should throw a more specific exception like APIAuthenticationException