001package gudusoft.gsqlparser.pp2;
002
003import gudusoft.gsqlparser.TSyntaxError;
004
005import java.util.ArrayList;
006import java.util.Collections;
007import java.util.List;
008
009/**
010 * Reserved exception type for a future strict pp2 mode.
011 *
012 * <p>The current engine always recovers ordinary parse failures through its
013 * fallback renderers and surfaces them as
014 * {@link FormatDiagnostic FormatDiagnostics} on {@link Pp2FormatResult}. It
015 * does not read {@link Pp2FormatOptions#tolerantMode} and does not currently
016 * construct this exception. The type is retained so strict-mode support can
017 * be added without introducing a new public exception later.
018 */
019public class Pp2ParseException extends RuntimeException {
020
021    private static final long serialVersionUID = 1L;
022
023    private final List<TSyntaxError> parserErrors;
024
025    public Pp2ParseException(String message) {
026        super(message);
027        this.parserErrors = Collections.emptyList();
028    }
029
030    public Pp2ParseException(String message, List<TSyntaxError> parserErrors) {
031        super(message);
032        this.parserErrors = parserErrors == null
033            ? Collections.<TSyntaxError>emptyList()
034            : Collections.unmodifiableList(new ArrayList<TSyntaxError>(parserErrors));
035    }
036
037    public Pp2ParseException(String message, Throwable cause) {
038        super(message, cause);
039        this.parserErrors = Collections.emptyList();
040    }
041
042    /** Immutable view of the parser diagnostics that triggered this failure. */
043    public List<TSyntaxError> getParserErrors() {
044        return parserErrors;
045    }
046}