diff --git a/src/Elmah.Io.HResults/Facilities/FacilityInternetResolver.cs b/src/Elmah.Io.HResults/Facilities/FacilityInternetResolver.cs new file mode 100644 index 0000000..0211607 --- /dev/null +++ b/src/Elmah.Io.HResults/Facilities/FacilityInternetResolver.cs @@ -0,0 +1,106 @@ +namespace Elmah.Io.HResults.Facilities +{ + // Sources: + // - https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ms762295(v=vs.85) + internal class FacilityInternetResolver : FacilityResolverBase + { + public FacilityInternetResolver() : base(12, "FACILITY_INTERNET") + { + } + + internal override Code Resolve(bool failure, int code) + { + return code switch + { + 58118 => new Code(code, "XML_E_FORMATINDEX_BADINDEX", "The value passed in to formatIndex must be greater than 0."), + 58119 => new Code(code, "XML_E_FORMATINDEX_BADFORMAT", "Invalid format string."), + 58240 => new Code(code, "XML_E_EXPECTED_TOKEN", "Expected token %1 found %2."), + 58241 => new Code(code, "XML_E_UNEXPECTED_TOKEN", "Unexpected token %1."), + 58625 => new Code(code, "XML_E_MISSINGEQUALS", "Missing equals sign between attribute and attribute value."), + 58626 => new Code(code, "XML_E_MISSINGQUOTE", "A string literal was expected, but no opening quote character was found."), + 58627 => new Code(code, "XML_E_COMMENTSYNTAX", "Incorrect syntax was used in a comment."), + 58628 => new Code(code, "XML_E_BADSTARTNAMECHAR", "A name was started with an invalid character."), + 58629 => new Code(code, "XML_E_BADNAMECHAR", "A name contained an invalid character."), + 58630 => new Code(code, "XML_E_BADCHARINSTRING", "A string literal contained an invalid character."), + 58631 => new Code(code, "XML_E_XMLDECLSYNTAX", "Invalid syntax for an XML declaration."), + 58632 => new Code(code, "XML_E_BADCHARDATA", "An invalid character was found in text content."), + 58633 => new Code(code, "XML_E_MISSINGWHITESPACE", "Required white space was missing."), + 58634 => new Code(code, "XML_E_EXPECTINGTAGEND", "The character '>' was expected."), + 58635 => new Code(code, "XML_E_BADCHARINDTD", "Invalid character found in document type definition (DTD)."), + 58636 => new Code(code, "XML_E_BADCHARINDECL", "An invalid character was found inside a DTD declaration."), + 58637 => new Code(code, "XML_E_MISSINGSEMICOLON", "A semicolon character was expected."), + 58638 => new Code(code, "XML_E_BADCHARINENTREF", "An invalid character was found inside an entity reference."), + 58639 => new Code(code, "XML_E_UNBALANCEDPAREN", "Unbalanced parentheses."), + 58640 => new Code(code, "XML_E_EXPECTINGOPENBRACKET", "An opening '[' character was expected."), + 58641 => new Code(code, "XML_E_BADENDCONDSECT", "Invalid syntax in a conditional section."), + 58642 => new Code(code, "XML_E_INTERNALERROR", "Internal error."), + 58643 => new Code(code, "XML_E_UNEXPECTED_WHITESPACE", "White space is not allowed at this location."), + 58644 => new Code(code, "XML_E_INCOMPLETE_ENCODING", "End of file reached in invalid state for current encoding."), + 58645 => new Code(code, "XML_E_BADCHARINMIXEDMODEL", "Mixed content model cannot contain this character."), + 58646 => new Code(code, "XML_E_MISSING_STAR", "Mixed content model must be defined as zero or more('*')."), + 58647 => new Code(code, "XML_E_BADCHARINMODEL", "Invalid character in content model."), + 58648 => new Code(code, "XML_E_MISSING_PAREN", "Missing parenthesis."), + 58649 => new Code(code, "XML_E_BADCHARINENUMERATION", "Invalid character found in ATTLIST enumeration."), + 58650 => new Code(code, "XML_E_PIDECLSYNTAX", "Invalid syntax in processing instruction declaration."), + 58651 => new Code(code, "XML_E_EXPECTINGCLOSEQUOTE", "A single or double closing quote character (\' or \") is missing."), + 58652 => new Code(code, "XML_E_MULTIPLE_COLONS", "Multiple colons are not allowed in a name."), + 58653 => new Code(code, "XML_E_INVALID_DECIMAL", "Invalid character for decimal digit."), + 58654 => new Code(code, "XML_E_INVALID_HEXIDECIMAL", "Invalid character for hexadecimal digit."), + 58655 => new Code(code, "XML_E_INVALID_UNICODE", "Invalid Unicode character value for this platform."), + 58656 => new Code(code, "XML_E_WHITESPACEORQUESTIONMARK", "Expecting white space or '?'."), + 58704 => new Code(code, "XML_E_SUSPENDED", "The parser is suspended."), + 58705 => new Code(code, "XML_E_STOPPED", "The parser is stopped."), + 58706 => new Code(code, "XML_E_UNEXPECTEDENDTAG", "End tag was not expected at this location."), + 58707 => new Code(code, "XML_E_UNCLOSEDTAG", "The following tags were not closed: %1."), + 58708 => new Code(code, "XML_E_DUPLICATEATTRIBUTE", "Duplicate attribute."), + 58709 => new Code(code, "XML_E_MULTIPLEROOTS", "Only one top level element is allowed in an XML document."), + 58710 => new Code(code, "XML_E_INVALIDATROOTLEVEL", "Invalid at the top level of the document."), + 58711 => new Code(code, "XML_E_BADXMLDECL", "Invalid XML declaration."), + 58712 => new Code(code, "XML_E_MISSINGROOT", "XML document must have a top level element."), + 58713 => new Code(code, "XML_E_UNEXPECTEDEOF", "Unexpected end of file."), + 58714 => new Code(code, "XML_E_BADPEREFINSUBSET", "Parameter entities cannot be used inside markup declarations in an internal subset."), + 58715 => new Code(code, "XML_E_PE_NESTING", "The replacement text for a parameter entity must be properly nested with parenthesized groups."), + 58716 => new Code(code, "XML_E_INVALID_CDATACLOSINGTAG", "The literal string ']]>' is not allowed in element content."), + 58717 => new Code(code, "XML_E_UNCLOSEDPI", "Processing instruction was not closed."), + 58718 => new Code(code, "XML_E_UNCLOSEDSTARTTAG", "Element was not closed."), + 58719 => new Code(code, "XML_E_UNCLOSEDENDTAG", "End element was missing the character '>'."), + 58720 => new Code(code, "XML_E_UNCLOSEDSTRING", "A string literal was not closed."), + 58721 => new Code(code, "XML_E_UNCLOSEDCOMMENT", "A comment was not closed."), + 58722 => new Code(code, "XML_E_UNCLOSEDDECL", "A declaration was not closed."), + 58723 => new Code(code, "XML_E_UNCLOSEDMARKUPDECL", "A markup declaration was not closed."), + 58724 => new Code(code, "XML_E_UNCLOSEDCDATA", "A CDATA section was not closed."), + 58725 => new Code(code, "XML_E_BADDECLNAME", "Declaration has an invalid name."), + 58726 => new Code(code, "XML_E_BADEXTERNALID", "External ID is invalid."), + 58727 => new Code(code, "XML_E_BADELEMENTINDTD", "An XML element is not allowed inside a DTD."), + 58728 => new Code(code, "XML_E_RESERVEDNAMESPACE", "The namespace prefix is not allowed to start with the reserved string \"xml\"."), + 58729 => new Code(code, "XML_E_EXPECTING_VERSION", "The 'version' attribute is required at this location."), + 58730 => new Code(code, "XML_E_EXPECTING_ENCODING", "The 'encoding' attribute is required at this location."), + 58731 => new Code(code, "XML_E_EXPECTING_NAME", "At least one name is required at this location."), + 58732 => new Code(code, "XML_E_UNEXPECTED_ATTRIBUTE", "The specified attribute was not expected at this location. The attribute may be case sensitive."), + 58733 => new Code(code, "XML_E_ENDTAGMISMATCH", "End tag '%2' does not match the start tag '%1'."), + 58734 => new Code(code, "XML_E_INVALIDENCODING", "System does not support the specified encoding."), + 58735 => new Code(code, "XML_E_INVALIDSWITCH", "Switch from current encoding to specified encoding not supported."), + 58736 => new Code(code, "XML_E_EXPECTING_NDATA", "NDATA keyword is missing."), + 58737 => new Code(code, "XML_E_INVALID_MODEL", "Content model is invalid."), + 58738 => new Code(code, "XML_E_INVALID_TYPE", "Invalid type defined in ATTLIST."), + 58739 => new Code(code, "XML_E_INVALIDXMLSPACE", "XML space attribute has invalid value. Must specify 'default' or 'preserve'."), + 58740 => new Code(code, "XML_E_MULTI_ATTR_VALUE", "Multiple names found in attribute value when only one was expected."), + 58741 => new Code(code, "XML_E_INVALID_PRESENCE", "Invalid ATTDEF declaration. Expected #REQUIRED, #IMPLIED or #FIXED."), + 58742 => new Code(code, "XML_E_BADXMLCASE", "The name 'xml' is reserved and must be lowercase."), + 58743 => new Code(code, "XML_E_CONDSECTINSUBSET", "Conditional sections are not allowed in an internal subset."), + 58744 => new Code(code, "XML_E_CDATAINVALID", "CDATA is not allowed in a DTD."), + 58745 => new Code(code, "XML_E_INVALID_STANDALONE", "The standalone attribute must have the value 'yes' or 'no'."), + 58746 => new Code(code, "XML_E_UNEXPECTED_STANDALONE", "The standalone attribute cannot be used in external entities."), + 58747 => new Code(code, "XML_E_DOCTYPE_IN_DTD", "Cannot have a DOCTYPE declaration in a DTD."), + 58748 => new Code(code, "XML_E_MISSING_ENTITY", "Reference to undefined entity."), + 58749 => new Code(code, "XML_E_ENTITYREF_INNAME", "Entity reference is resolved to an invalid name character."), + 58750 => new Code(code, "XML_E_DOCTYPE_OUTSIDE_PROLOG", "Cannot have a DOCTYPE declaration outside of a prolog."), + 58751 => new Code(code, "XML_E_INVALID_VERSION", "Invalid version number."), + 58752 => new Code(code, "XML_E_DTDELEMENT_OUTSIDE_DTD", "Cannot have a DTD declaration outside of a DTD."), + 58753 => new Code(code, "XML_E_DUPLICATEDOCTYPE", "Cannot have multiple DOCTYPE declarations."), + 58754 => new Code(code, "XML_E_RESOURCE", "Error processing resource '%1'."), + _ => Unknown(code), + }; + } + } +} diff --git a/src/Elmah.Io.HResults/IntExtensions.cs b/src/Elmah.Io.HResults/IntExtensions.cs index 9f5bf34..2637a32 100644 --- a/src/Elmah.Io.HResults/IntExtensions.cs +++ b/src/Elmah.Io.HResults/IntExtensions.cs @@ -14,7 +14,8 @@ internal static class IntExtensions new FacilityScardResolver(), new FacilitySecurityResolver(), new FacilitySetupapiResolver(), new FacilityStorageResolver(), new FacilityTpmServicesResolver(), new FacilityTpmSoftwareResolver(), new FacilityUrtResolver(), new FacilityUsermodeFilterManagerResolver(), new FacilityWin32Resolver(), - new FacilityWindowsResolver(), new FacilityControlResolver(), new FacilityWincodecDwriteDwmResolver() + new FacilityWindowsResolver(), new FacilityControlResolver(), new FacilityWincodecDwriteDwmResolver(), + new FacilityInternetResolver() }; internal static Code ToCode(this int code, bool failure, int facility) diff --git a/test/Elmah.Io.HResults.Test/HResultTest.cs b/test/Elmah.Io.HResults.Test/HResultTest.cs index 8cebbd6..4b2ca80 100644 --- a/test/Elmah.Io.HResults.Test/HResultTest.cs +++ b/test/Elmah.Io.HResults.Test/HResultTest.cs @@ -9,6 +9,7 @@ public class HResultTest [TestCase(-2147024894, "0x80070002", 7, "FACILITY_WIN32", 2, "ERROR_FILE_NOT_FOUND")] [TestCase(-2146232832, "0x80131600", 19, "FACILITY_URT", 5632, "COR_E_APPLICATION")] [TestCase(-2146828283, "0x800A0005", 10, "FACILITY_CONTROL", 5, "CTL_E_ILLEGALFUNCTIONCALL")] + [TestCase(-1072896680, "0xC00CE558", 12, "FACILITY_INTERNET", 58712, "XML_E_MISSINGROOT")] public void CanParseKnownFailure(int hresult, string expectedHex, int expectedFacilityCode, string expectedFacilityName, int expectedCode, string expectedName) { var res = HResult.Parse(hresult);