Sage.SageHelpException.Create C# (CSharp) Method

Create() static private method

static private Create ( Exception ex, string path = null, ProblemType suggestedProblem = ProblemType.Unknown ) : SageHelpException
ex System.Exception
path string
suggestedProblem ProblemType
return SageHelpException
        internal static SageHelpException Create(Exception ex, string path = null, ProblemType suggestedProblem = ProblemType.Unknown)
        {
            ProblemInfo problem = new ProblemInfo(ProblemType.Unknown);
            if (ex is XmlException)
            {
                if (ex.Message.Contains("undeclared prefix"))
                    problem = new ProblemInfo(ProblemType.MissingNamespaceDeclaration, path);

                else if (path != null && (path.EndsWith("html") || path.EndsWith("htm")))
                    problem = new ProblemInfo(ProblemType.InvalidHtmlMarkup, path);

                else
                    problem = new ProblemInfo(ProblemType.InvalidMarkup, path);
            }
            else
            {
                var typeName = ex.GetType().Name;
                if (parsers.ContainsKey(typeName))
                    problem = parsers[typeName].Invoke(ex);
            }

            if (problem.Type == ProblemType.Unknown && suggestedProblem != ProblemType.Unknown)
                problem.Type = suggestedProblem;

            var result = new SageHelpException(problem) { Exception = ex };
            return result;
        }