コード例 #1
0
        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);
        }
コード例 #2
0
        private void OnOperationError(UIError error)
        {
            onOperationError?.Invoke(this, error);
            FinalizedOperation();

            PackageManagerOperationErrorAnalytics.SendEvent(GetType().Name, error);
        }
コード例 #3
0
ファイル: Alert.cs プロジェクト: leek9d/UnityCsReference
        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);
        }
コード例 #4
0
ファイル: UpmClient.cs プロジェクト: leek9d/UnityCsReference
 private void OnProcessExtraFetchError(UIError error, string productId = null)
 {
     if (!string.IsNullOrEmpty(productId))
     {
         onProductPackageFetchError?.Invoke(productId, error);
     }
 }
コード例 #5
0
 private void OnRegistryOperationError(string name, UIError error)
 {
     if ((draft.original?.name ?? draft.name) == name)
     {
         draft.errorMessage = error.message;
         RefreshErrorBox();
     }
 }
コード例 #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);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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();
            }
        }
コード例 #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 });
            }
        }
コード例 #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);
            });
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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();
 }
コード例 #14
0
 private void OnRefreshOperationError(UIError error)
 {
     UpdateStatusMessage();
 }
コード例 #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();
        }
コード例 #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));
 }
コード例 #17
0
 private void OnOperationError(UIError error)
 {
     onOperationError?.Invoke(this, error);
     FinalizedOperation();
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #20
0
 public void SetUpmPackageFetchError(UIError error)
 {
     m_Errors.Add(error);
     m_Tag &= ~(PackageTag.Downloadable | PackageTag.Importable);
 }
コード例 #21
0
 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];
 }