Example #1
0
        public void HandleError(Exception ex, string additionalInfo = "")
        {
            var lastFmException = GetLastFmException(ex);

            switch (lastFmException.ErrorCode)
            {
            case ErrorCode.InvalidApiKey:
            case ErrorCode.ServiceOffline:
            case ErrorCode.ApiKeySuspended:
            case ErrorCode.RateLimitExceeded:
                _servicesStatus.SetStatus(WebServiceType.LastFm, false, GetUserFriendlyMessage(lastFmException.ErrorCode));
                _errorHandler.Error(GetNewException(lastFmException, additionalInfo), GetUserFriendlyMessage(lastFmException.ErrorCode));
                break;

            case ErrorCode.ConnectionFailed:
                _servicesStatus.SetStatus(WebServiceType.Web, false);
                _errorHandler.Warn(GetNewException(lastFmException, additionalInfo));
                return;

            case ErrorCode.InvalidSessionKey:
            case ErrorCode.UnauthorizedToken:
            case ErrorCode.AuthenticationFailed:
            case ErrorCode.UserNotLoggedIn:
                // Change this to add a way of resolving session issues instead
                _servicesStatus.SetStatus(WebServiceType.LastFm, false, GetUserFriendlyMessage(lastFmException.ErrorCode));
                _errorHandler.Error(GetNewException(lastFmException, additionalInfo), GetUserFriendlyMessage(lastFmException.ErrorCode));
                break;

            default:
                _errorHandler.Warn(GetNewException(lastFmException, additionalInfo));
                break;
            }
        }
 private void Handle(WebServiceType type, ServiceAuthenticationException ex, string additionalErrorInfo)
 {
     _servicesStatus.SetStatus(type, false, ex.Message);
     _errorHandler.Error(new Exception(additionalErrorInfo, ex), $"Authentication error for {type} service:"
                         + Environment.NewLine
                         + Environment.NewLine
                         + ex.Message);
 }