Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
Error type and to_string
function.
type t = [
| `Decoding_error of string * string
| `Bad_token of string * string * string
| `Unexpected_eoi of string
| `Bad_document of string
| `Unmatched_start_tag of string
| `Unmatched_end_tag of string
| `Bad_namespace of string
| `Misnested_tag of string * string
| `Bad_content of string
]
Errors reported by the parsers. A few of these are also used by the writers.
`Decoding_error (bytes, encoding)
is reported by the decoders in module 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 detects a &
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. where
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 s
can't 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 `Bad_content "table"
.