libexpr: Throw the correct error in toJSON

BaseError::addTrace(...) returns a BaseError, but we want to
throw a TypeError instead.

Fixes #6336.
This commit is contained in:
Daniel Pauls 2022-03-30 15:41:25 +02:00
parent 22522722a6
commit fa83b865a2

View file

@ -84,7 +84,8 @@ void printValueAsJSON(EvalState & state, bool strict,
.msg = hintfmt("cannot convert %1% to JSON", showType(v)),
.errPos = v.determinePos(pos)
});
throw e.addTrace(pos, hintfmt("message for the trace"));
e.addTrace(pos, hintfmt("message for the trace"));
throw e;
}
}