package markup

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Error type and to_string function.

type t = [
  1. | `Decoding_error of string * string
  2. | `Bad_token of string * string * string
  3. | `Unexpected_eoi of string
  4. | `Bad_document of string
  5. | `Unmatched_start_tag of string
  6. | `Unmatched_end_tag of string
  7. | `Bad_namespace of string
  8. | `Misnested_tag of string * string * (string * string) list
  9. | `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, attributes) is reported by the HTML parser when a tag appears where it is not allowed. For example, if the input has a <body class=""> tag inside a <p> tag, the parser will report `Misnested_tag ("body", "p", [("class", "")]).
  • `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".
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.

OCaml

Innovation. Community. Security.