2 * Copyright (c) 2019 Pantheon Technologies, s.r.o. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.xpath.impl;
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import javax.xml.xpath.XPathExpressionException;
12 import org.antlr.v4.runtime.BaseErrorListener;
13 import org.antlr.v4.runtime.RecognitionException;
14 import org.antlr.v4.runtime.Recognizer;
15 import org.eclipse.jdt.annotation.Nullable;
17 final class CapturingErrorListener extends BaseErrorListener {
18 @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR",
19 justification = "SB does not grok CDT")
20 private @Nullable XPathExpressionException error;
23 public void syntaxError(final @Nullable Recognizer<?, ?> recognizer, final @Nullable Object offendingSymbol,
24 final int line, final int charPositionInLine, final @Nullable String msg,
25 final @Nullable RecognitionException cause) {
26 final XPathExpressionException ex = Utils.wrapException(cause, "%s", msg);
30 error.addSuppressed(ex);
34 void reportError() throws XPathExpressionException {