standards-c-sharp

Only throw exceptions in exceptional circumstances

Don’t

try
{
    _authenticationService.LogUserIn(username, password);
}
catch (InvalidCredentialsException)
{
    // show "Invalid credentials" message
}

Do

var authResult = _authenticationService.LogUserIn(username, password);
// instead of using an exception to indicate (expected) failure, we use a control statement
if (!authResult.IsAuthenticated) 
{
    // show "Invalid credentials" message
}