001package org.jsoup.parser;
002
003/**
004 * A Parse Error records an error in the input HTML that occurs in either the tokenisation or the tree building phase.
005 */
006public class ParseError {
007    private int pos;
008    private String errorMsg;
009
010    ParseError(int pos, String errorMsg) {
011        this.pos = pos;
012        this.errorMsg = errorMsg;
013    }
014
015    ParseError(int pos, String errorFormat, Object... args) {
016        this.errorMsg = String.format(errorFormat, args);
017        this.pos = pos;
018    }
019
020    /**
021     * Retrieve the error message.
022     * @return the error message.
023     */
024    public String getErrorMessage() {
025        return errorMsg;
026    }
027
028    /**
029     * Retrieves the offset of the error.
030     * @return error offset within input
031     */
032    public int getPosition() {
033        return pos;
034    }
035
036    @Override
037    public String toString() {
038        return pos + ": " + errorMsg;
039    }
040}