Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improves error message presented to user

  • Loading branch information...
commit de1ed70edf5cb5b436935d90021ea6da7045ef64 1 parent 982b63c
@martin-seomoz martin-seomoz authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 Json/ParserShiftReduce.y
View
7 Json/ParserShiftReduce.y
@@ -9,6 +9,7 @@
#include "ParserInterface.h"
#include "LexerJson.h"
#include <stdexcept>
+#include <sstream>
using ThorsAnvil::Json::ParserInterface;
using ThorsAnvil::Json::JsonValue;
@@ -109,6 +110,10 @@ int ThorsAnvil::Json::yylex(void*, LexerJson& lexer, ParserInterface& pi)
void yy::ParserShiftReduce::error(yy::location const&, std::string const& msg)
{
- throw ThorsAnvil::Json::ParsingError(msg);
+ std::string lastToken(lexer.YYText(), lexer.YYText() + lexer.YYLeng());
+ std::stringstream extended;
+ extended << msg << " -> Last Token: " << lastToken << " At line: " << lexer.lineno();
+
+ throw ThorsAnvil::Json::ParsingError(extended.str());
}
Please sign in to comment.
Something went wrong with that request. Please try again.