Merge pull request #4351 from Ma27/json-errtrace

primops/fromJSON: add error position in case of parse error
This commit is contained in:
Eelco Dolstra 2020-12-14 11:27:44 +01:00 committed by GitHub
commit 27b5ff354e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1621,7 +1621,12 @@ static RegisterPrimOp primop_toJSON({
static void prim_fromJSON(EvalState & state, const Pos & pos, Value * * args, Value & v)
{
string s = state.forceStringNoCtx(*args[0], pos);
try {
parseJSON(state, s, v);
} catch (JSONParseError &e) {
e.addTrace(pos, "while decoding a JSON string");
throw e;
}
}
static RegisterPrimOp primop_fromJSON({