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");
}
}