XmlSyntaxError
import { XmlSyntaxError } from "jsr:@ende/xml";class
class XmlSyntaxError extends SyntaxErrorError thrown when XML parsing fails.
Example: Usage
import { XmlSyntaxError } from "@ende/xml/types";
import { assertInstanceOf } from "@ende/assert";
const error = new XmlSyntaxError("Unexpected character", { line: 10, column: 5, offset: 150 });
assertInstanceOf(error, SyntaxError);
Constructors
constructor
new XmlSyntaxError(message: string, position: XmlPosition)Constructs a new XmlSyntaxError.
The position is appended to the message, unless position.line is 0
(the sentinel used when position tracking is disabled).
message: stringThe error message describing the syntax issue.
position: XmlPositionThe position in the XML source where the error occurred.
Properties
line
readonly line: numberThe line number where the error occurred (1-indexed), or 0 when
position tracking is disabled.
Example: Usage
import { XmlSyntaxError } from "@ende/xml/types";
import { assertEquals } from "@ende/assert";
const error = new XmlSyntaxError("Test", { line: 5, column: 10, offset: 50 });
assertEquals(error.line, 5);
column
readonly column: numberThe column number where the error occurred (1-indexed), or 0 when
position tracking is disabled.
Example: Usage
import { XmlSyntaxError } from "@ende/xml/types";
import { assertEquals } from "@ende/assert";
const error = new XmlSyntaxError("Test", { line: 5, column: 10, offset: 50 });
assertEquals(error.column, 10);
offset
readonly offset: numberThe character offset in the input string where the error occurred (in UTF-16 code units, 0-indexed).
Example: Usage
import { XmlSyntaxError } from "@ende/xml/types";
import { assertEquals } from "@ende/assert";
const error = new XmlSyntaxError("Test", { line: 5, column: 10, offset: 50 });
assertEquals(error.offset, 50);