示例#1
0
 internal UpdatableHelpExceptionContext(UpdatableHelpSystemException exception)
 {
     this._exception = exception;
     this._modules   = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
     this._cultures  = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
 }
 internal UpdatableHelpExceptionContext(UpdatableHelpSystemException exception)
 {
     this._exception = exception;
     this._modules = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
     this._cultures = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
 }
        /// <summary>
        /// Processes an exception for help cmdlets
        /// </summary>
        /// <param name="moduleName">module name</param>
        /// <param name="culture">culture info</param>
        /// <param name="e">exception to check</param>
        internal void ProcessException(string moduleName, string culture, Exception e)
        {
            UpdatableHelpSystemException except = null;

            if (e is UpdatableHelpSystemException)
            {
                except = (UpdatableHelpSystemException)e;
            }
#if !CORECLR
            else if (e is WebException)
            {
                except = new UpdatableHelpSystemException("UnableToConnect",
                    StringUtil.Format(HelpDisplayStrings.UnableToConnect), ErrorCategory.InvalidOperation, null, e);
            }
#endif
            else if (e is PSArgumentException)
            {
                except = new UpdatableHelpSystemException("InvalidArgument",
                    e.Message, ErrorCategory.InvalidArgument, null, e);
            }
            else
            {
                except = new UpdatableHelpSystemException("UnknownErrorId",
                    e.Message, ErrorCategory.InvalidOperation, null, e);
            }

            if (!_exceptions.ContainsKey(except.FullyQualifiedErrorId))
            {
                _exceptions.Add(except.FullyQualifiedErrorId, new UpdatableHelpExceptionContext(except));
            }

            _exceptions[except.FullyQualifiedErrorId].Modules.Add(moduleName);

            if (culture != null)
            {
                _exceptions[except.FullyQualifiedErrorId].Cultures.Add(culture);
            }
        }