I was just making tests to see what response I get when trying to sign in with either an incorrect username or password.
Surprisingly, this returns a RequestFailedException rather than an AuthenticationException. The ErrorCode for this is also unexpected: 0 (zero)
The InnerException is a private WebRequestException whose Message is a json string containing the status code 400. According to REST docs 400 means “bad request”.
Now, in order to tell the user that his username or password is incorrect, at the current state I would have to parse the WebRequestException json string in order to compare the “title” which contains “WRONG_USERNAME_PASSWORD” or perhaps simply present the “detail” string which is “invalid username or password”.
I feel like this case should be handled as an AuthenticationException with an appropriate ErrorCode, so that it can be caught easily and presented nicely to the user. This would make the code less brittle (not depending on Json and string compare) and more straightforward.