BeatMachine.Model.DataModel.LoadCatalogIdNeedsToCheckCatalogId_CatalogUpdateCompleted C# (CSharp) Method

LoadCatalogIdNeedsToCheckCatalogId_CatalogUpdateCompleted() public method

public LoadCatalogIdNeedsToCheckCatalogId_CatalogUpdateCompleted ( object sender, BeatMachine.EchoNest.EchoNestApiEventArgs e ) : void
sender object
e BeatMachine.EchoNest.EchoNestApiEventArgs
return void
        void LoadCatalogIdNeedsToCheckCatalogId_CatalogUpdateCompleted(
            object sender, EchoNestApiEventArgs e)
        {
            if (e.Error != null)
            {
                if (e.Error is WebExceptionWrapper)
                {
                    // Transient network error
                    logger.Error("Verifying remote CatalogID failed, retrying");
                    LoadCatalogIdNeedsToRunAgain();
                }
                else if (e.Error is EchoNestApiException)
                {
                    EchoNestApiException er = e.Error as EchoNestApiException;
                    if (er.Code == EchoNestApiException.EchoNestApiExceptionType.InvalidParameter &&
                        String.Equals(er.Message, "This catalog does not exist"))
                    {
                        // They either didn't have a CatalogId in local storage, or
                        // they did have one, but it wasn't on the cloud service. In
                        // both cases, we create a new one
                        logger.Debug("Verifying remote CatalogID succeeded, but it's missing");
                        LoadCatalogIdNeedsToCreateCatalog();
                    }
                }
            }
            else
            {
                logger.Debug("Verifying remote CatalogID succeeded, it's there");
                CatalogId = (string)e.UserState;
                logger.Info("Completed LoadCatalogId");
            }
        }