private void OnErrorMessage(string errorMessage, int operationErrorCode = -1, UIError.Attribute attr = UIError.Attribute.None)
        {
            m_State = DownloadState.Error;

            if ((attr & UIError.Attribute.IsWarning) != 0)
            {
                Debug.LogWarning($"{k_ConsoleLogPrefix} {errorMessage}");
            }
            else
            {
                Debug.LogError($"{k_ConsoleLogPrefix} {errorMessage}");
            }

            attr |= UIError.Attribute.IsDetailInConsole;
            if (operationErrorCode == 403)
            {
                m_ErrorMessage = k_ForbiddenErrorMessage;
            }
            else
            {
                attr          |= UIError.Attribute.IsClearable;
                m_ErrorMessage = k_DownloadErrorMessage;
            }

            var error = new UIError(UIErrorCode.AssetStoreOperationError, m_ErrorMessage, attr, operationErrorCode);

            onOperationError?.Invoke(this, error);
            onOperationFinalized?.Invoke(this);

            PackageManagerOperationErrorAnalytics.SendEvent(GetType().Name, error);
        }
        private void OnOperationError(UIError error)
        {
            onOperationError?.Invoke(this, error);
            FinalizedOperation();

            PackageManagerOperationErrorAnalytics.SendEvent(GetType().Name, error);
        }
Beispiel #3
0
        public void SetError(UIError error, IPackageVersion packageVersion = null)
        {
            var state   = error.HasAttribute(UIError.Attribute.IsWarning) ? PackageState.Warning : PackageState.Error;
            var message = state == PackageState.Warning ? L10n.Tr("A warning occurred") : L10n.Tr("An error occurred");

            if (!string.IsNullOrEmpty(error.message))
            {
                message = string.Format("{0}: {1}", message, error.message);
            }
            if (error.HasAttribute(UIError.Attribute.IsDetailInConsole))
            {
                message = string.Format(L10n.Tr("{0} See console for more details."), message);
            }

            var addClass        = state == PackageState.Warning ? "warning" : "error";
            var removeFromClass = state == PackageState.Warning ? "error" : "warning";

            alertContainer.RemoveFromClassList(removeFromClass);
            alertContainer.AddClasses(addClass);

            if (!string.IsNullOrEmpty(error.readMoreURL))
            {
                ShowReadMoreLink(error, packageVersion);
            }
            else
            {
                HideReadMoreLink();
            }

            alertMessage.text = message;
            UIUtils.SetElementDisplay(this, true);
        }
Beispiel #4
0
 private void OnProcessExtraFetchError(UIError error, string productId = null)
 {
     if (!string.IsNullOrEmpty(productId))
     {
         onProductPackageFetchError?.Invoke(productId, error);
     }
 }
 private void OnRegistryOperationError(string name, UIError error)
 {
     if ((draft.original?.name ?? draft.name) == name)
     {
         draft.errorMessage = error.message;
         RefreshErrorBox();
     }
 }
Beispiel #6
0
 private void ShowReadMoreLink(UIError error, IPackageVersion packageVersion)
 {
     m_ReadMoreLinkAction = () =>
     {
         PackageManagerWindowAnalytics.SendEvent($"alertreadmore_{error.errorCode.ToString()}", packageVersion?.uniqueId);
         Application.OpenURL(error.readMoreURL);
     };
     UIUtils.SetElementDisplay(alertReadMoreLink, true);
 }
        public void AddError(UIError error)
        {
            if (error.errorCode == UIErrorCode.Forbidden)
            {
                m_Errors.Add(versions?.primary.isInstalled == true ? UIError.k_EntitlementError : UIError.k_EntitlementWarning);
                return;
            }

            m_Errors.Add(error);
        }
        private void OnExtraFetchError(IOperation operation, UIError error)
        {
            var searchOperation = operation as UpmSearchOperation;

            if (searchOperation.packageName == packageNameField.value.Trim())
            {
                SetError(L10n.Tr("Unable to find the package with the specified name.\nPlease check the name and try again."), true, false);
                ShowWithNewWindowSize();
            }
        }
Beispiel #9
0
        private void OnProductPackageFetchError(string productId, UIError error)
        {
            var purchaseInfo = m_AssetStoreCache.GetPurchaseInfo(productId);
            var productInfo  = m_AssetStoreCache.GetProductInfo(productId);

            if (productInfo != null)
            {
                var assetStorePackage        = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, purchaseInfo, productInfo);
                var assetStorePackageVersion = assetStorePackage.versions.primary as AssetStorePackageVersion;
                assetStorePackageVersion.SetUpmPackageFetchError(error);
                onPackagesChanged?.Invoke(new[] { assetStorePackage });
            }
        }
Beispiel #10
0
        public virtual void FetchDetail(long productId, Action <IPackage> doneCallbackAction = null)
        {
            m_AssetStoreRestAPI.GetProductDetail(productId, productDetail =>
            {
                IPackage package = null;
                var error        = productDetail.GetString("errorMessage");
                var idString     = productId.ToString();
                if (string.IsNullOrEmpty(error))
                {
                    var productInfo = AssetStoreProductInfo.ParseProductInfo(m_AssetStoreUtils, idString, productDetail);
                    if (productInfo == null)
                    {
                        package = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, idString, new UIError(UIErrorCode.AssetStoreClientError, L10n.Tr("Error parsing product details.")));
                    }
                    else
                    {
                        var oldProductInfo = m_AssetStoreCache.GetProductInfo(idString);
                        if (oldProductInfo == null || oldProductInfo.versionId != productInfo.versionId || oldProductInfo.versionString != productInfo.versionString)
                        {
                            if (string.IsNullOrEmpty(productInfo.packageName))
                            {
                                package = new AssetStorePackage(m_AssetStoreUtils, m_IOProxy, m_AssetStoreCache.GetPurchaseInfo(idString), productInfo, m_AssetStoreCache.GetLocalInfo(idString));
                            }
                            else
                            {
                                m_UpmClient.FetchForProduct(idString, productInfo.packageName);
                            }
                            m_AssetStoreCache.SetProductInfo(productInfo);
                        }
                    }
                }
                else
                {
                    var purchaseInfo = m_AssetStoreCache.GetPurchaseInfo(idString);
                    m_AssetStoreCache.RemoveProductInfo(idString);
                    var uiError = new UIError(UIErrorCode.AssetStoreClientError, error);
                    package     = new PlaceholderPackage(idString, purchaseInfo?.displayName ?? string.Empty, PackageType.AssetStore, PackageTag.Downloadable, PackageProgress.None, uiError);
                }

                if (package != null)
                {
                    onPackagesChanged?.Invoke(new[] { package });
                }

                doneCallbackAction?.Invoke(package);
            });
        }
Beispiel #11
0
        public static void SendEvent(string operationType, UIError error)
        {
            var servicesContainer    = ServicesContainer.instance;
            var editorAnalyticsProxy = servicesContainer.Resolve <EditorAnalyticsProxy>();

            if (!editorAnalyticsProxy.RegisterEvent(k_EventName))
            {
                return;
            }

            var parameters = new PackageManagerOperationErrorAnalytics
            {
                operation_type = operationType,
                message        = error.message,
                error_type     = error.errorCode.ToString(),
                status_code    = error.operationErrorCode,
                attributes     = error.attribute == UIError.Attribute.None ? new string[0] : error.attribute.ToString().Split(','),
                read_more_url  = error.readMoreURL ?? string.Empty
            };

            editorAnalyticsProxy.SendEventWithLimit(k_EventName, parameters);
        }
Beispiel #12
0
        public void SetError(UIError error, IPackageVersion packageVersion = null)
        {
            var message = string.Empty;

            if (!string.IsNullOrEmpty(error.message))
            {
                message = error.message;
            }
            if (error.HasAttribute(UIError.Attribute.IsDetailInConsole))
            {
                message = string.Format(L10n.Tr("{0} See console for more details."), message);
            }

            if (error.HasAttribute(UIError.Attribute.IsWarning))
            {
                alertContainer.RemoveFromClassList("error");
                alertContainer.AddClasses("warning");
            }
            else
            {
                alertContainer.RemoveFromClassList("warning");
                alertContainer.AddClasses("error");
            }

            if (!string.IsNullOrEmpty(error.readMoreURL))
            {
                ShowReadMoreLink(error, packageVersion);
            }
            else
            {
                HideReadMoreLink();
            }

            alertMessage.text = message;
            UIUtils.SetElementDisplay(this, true);
        }
Beispiel #13
0
 public PlaceholderPackage(string uniqueId, string displayName, PackageType type = PackageType.None, PackageTag tag = PackageTag.None, PackageProgress progress = PackageProgress.None, UIError error = null)
 {
     m_Type        = type;
     m_UniqueId    = uniqueId;
     m_Progress    = progress;
     m_VersionList = new PlaceholderVersionList(new PlaceholderPackageVersion(uniqueId, uniqueId, displayName, tag, error));
     m_Errors      = new List <UIError>();
     LinkPackageAndVersions();
 }
 private void OnRefreshOperationError(UIError error)
 {
     UpdateStatusMessage();
 }
Beispiel #15
0
        public AssetStorePackage(AssetStoreUtils assetStoreUtils, IOProxy ioProxy, string productId, UIError error)
        {
            ResolveDependencies(assetStoreUtils, ioProxy);

            m_Errors = new List <UIError> {
                error
            };
            m_Progress  = PackageProgress.None;
            m_Type      = PackageType.AssetStore;
            m_Name      = string.Empty;
            m_ProductId = productId;

            m_Images         = new List <PackageImage>();
            m_Links          = new List <PackageLink>();
            m_VersionList    = new AssetStoreVersionList(assetStoreUtils, ioProxy);
            m_UpmVersionList = new UpmVersionList();

            m_Labels             = new List <string>();
            m_PurchasedTimeTicks = 0;

            LinkPackageAndVersions();
        }
Beispiel #16
0
 private void OnPackagesGetCacheRootOperationError(UIError error)
 {
     packagesCacheDropdown.SetEnabled(false);
     DisplayPackagesCacheErrorBox(HelpBoxMessageType.Error, string.Format(L10n.Tr("Cannot get the Packages Cache location, reason: {0}."), error.message));
 }
 private void OnOperationError(UIError error)
 {
     onOperationError?.Invoke(this, error);
     FinalizedOperation();
 }
Beispiel #18
0
 private void OnPackagesClearCacheRootOperationError(UIError error)
 {
     DisplayPackagesCacheErrorBox(HelpBoxMessageType.Error, string.Format(L10n.Tr("Cannot reset the Packages Cache location to default, reason: {0}."), error.message));
 }
Beispiel #19
0
 private void OnPackagesSetCacheRootOperationError(UIError error, string path)
 {
     DisplayPackagesCacheErrorBox(HelpBoxMessageType.Error, string.Format(L10n.Tr("Cannot set the Packages Cache location to '{0}', reason: {1}."), path, error.message));
 }
Beispiel #20
0
 public void SetUpmPackageFetchError(UIError error)
 {
     m_Errors.Add(error);
     m_Tag &= ~(PackageTag.Downloadable | PackageTag.Importable);
 }
 public PlaceholderPackageVersion(string packageUniqueId, string uniqueId, string displayName, PackageTag tag = PackageTag.None, UIError error = null)
 {
     m_PackageUniqueId = packageUniqueId;
     m_UniqueId        = uniqueId;
     m_DisplayName     = displayName;
     m_Tag             = tag;
     m_Version         = new SemVersion(0);
     m_Errors          = error != null ? new UIError[] { error } : new UIError[0];
 }