Skip to content

DecodeError

Raised when decode is given XML that is not well-formed, or that uses a feature it doesn't support.

Example

try
  decode "<a><b></a>"
catch DecodeError: err
  echo "bad XML at line $(err.line), column $(err.column)"

Inherits from: std.DataError

Fields

column @ Int [get]

Column of the fault, counting characters from 1.

kind @ (:SYNTAX: | :EOF: | :ILL_FORMED: | :REFERENCE: | :NAMESPACE:) [get]

What is wrong with the document.

Kind Meaning
:SYNTAX: A character is out of place, such as in malformed attribute markup.
:EOF: The input ends inside markup, an element, or a reference.
:ILL_FORMED: The markup breaks an XML rule, such as a mismatched end tag, an invalid name, a duplicate attribute, a forbidden character, or a root count other than one.
:REFERENCE: A reference names an entity other than the five predefined ones, or a character that is invalid or forbidden.
:NAMESPACE: A prefix is not bound, or a namespace binding is forbidden.
line @ Int [get]

Line of the fault, counting from 1.

When the fault is in a tag, text, or reference as a whole, such as an invalid name, this is where that tag, text, or reference starts.