Merge pull request #1723 from chund/master
Improve error message in exceptions
This commit is contained in:
commit
efc89fd73c
|
@ -138,4 +138,5 @@ YYYY/MM/DD, github id, Full name, email
|
|||
2017/02/14, xied75, Dong Xie, xied75@gmail.com
|
||||
2017/02/20, Thomasb81, Thomas Burg, thomasb81@gmail.com
|
||||
2017/02/26, jvasileff, John Vasileff, john@vasileff.com
|
||||
2017/03/03, chund, Christian Hund, christian.hund@gmail.com
|
||||
2017/03/08, harry-tallbelt, Igor Vysokopoyasny, harry.tallbelt@gmail.com
|
|
@ -10,6 +10,6 @@
|
|||
using namespace antlr4;
|
||||
|
||||
InputMismatchException::InputMismatchException(Parser *recognizer)
|
||||
: RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(),
|
||||
: RecognitionException("Input mismatch", recognizer, recognizer->getInputStream(), recognizer->getContext(),
|
||||
recognizer->getCurrentToken()) {
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "misc/IntervalSet.h"
|
||||
|
||||
#include "RecognitionException.h"
|
||||
#include "Token.h"
|
||||
|
||||
using namespace antlr4;
|
||||
|
||||
|
@ -20,7 +21,8 @@ RecognitionException::RecognitionException(Recognizer *recognizer, IntStream *in
|
|||
|
||||
RecognitionException::RecognitionException(const std::string &message, Recognizer *recognizer, IntStream *input,
|
||||
ParserRuleContext *ctx, Token *offendingToken)
|
||||
: RuntimeException(message), _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) {
|
||||
: RuntimeException(message + (offendingToken ? " near token " + offendingToken->getText() + " in line " + std::to_string(offendingToken->getLine()) : ""))
|
||||
, _recognizer(recognizer), _input(input), _ctx(ctx), _offendingToken(offendingToken) {
|
||||
InitializeInstanceFields();
|
||||
if (recognizer != nullptr) {
|
||||
_offendingState = recognizer->getState();
|
||||
|
|
Loading…
Reference in New Issue