Error type and
[ `Bad_content of string
| `Bad_document of string
| `Bad_namespace of string
| `Bad_token of string * string * string
| `Decoding_error of string * string
| `Misnested_tag of string * string
| `Unexpected_eoi of string
| `Unmatched_end_tag of string
| `Unmatched_start_tag of string ]
Errors reported by the parsers. A few of these are also used by the
`Decoding_error (bytes, encoding) is reported by the decoders in
Encoding. For example, if the UTF-8 decoder encounters a bare
0xA0 byte, it will report
`Decoding_error ("\xA0", "utf-8").
`Bad_token (token, where, s) is reported when there is a "local"
problem with the syntax of the input stream, such as an invalid
character or a duplicate attribute. For example, if the XML parser
& that is not part of an entity reference while reading an
attribute, it will report
`Bad_token ("&", "attribute", "replace with '&'")
`Unexpected_eoi where is reported by the parsers when the input ends
before an item, such as a tag, element, or comment, is closed.
describes the kind of item that wasn't closed.
`Bad_document s is reported by the parsers when there is a problem
with the top-level structure of the document. For example, if you are
parsing an input stream as XML with
~context:`Document, and the parser
finds an element after the root element, it will report
`Bad_document "not allowed after root element".
`Unmatched_start_tag name and
`Unmatched_end_tag name are reported
when tags aren't properly balanced. Note that not all unbalanced tags
are parse errors in HTML.
`Bad_namespace s is reported by parsers when the prefix
s can't be
resolved to a namespace, and by the writers when the namespace
be resolved to a prefix (or the default namespace).
`Misnested_tag (what, where) is reported by the HTML parser when a tag
appears where it is not allowed. For example, if the input has a
<body> tag inside a
<p> tag, the parser will report
`Misnested_tag ("body", "p").
`Bad_content where is reported by the HTML parser if an element has
content it is not allowed to have. For example, if there is stray text
at the top level of a
<table> element, the parser will report
val to_string :
?location:location -> t -> string
Converts an error to human-readable form. If
~location is specified,
location information is prepended to the output.