aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Pauls <daniel1708.de+git@gmail.com>2022-03-30 15:41:25 +0200
committerDaniel Pauls <daniel1708.de+git@gmail.com>2022-03-30 15:50:13 +0200
commitfa83b865a2cfd21d7e63eedb206c1e07c8178965 (patch)
tree2a82c0ce9c1369f83fb03f39f93a0ebab6295db6
parent22522722a6e62d723a8da4d3a0c0b7c6af09c05f (diff)
libexpr: Throw the correct error in toJSON
BaseError::addTrace(...) returns a BaseError, but we want to throw a TypeError instead. Fixes #6336.
-rw-r--r--src/libexpr/value-to-json.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc
index 517da4c01..7b35abca2 100644
--- a/src/libexpr/value-to-json.cc
+++ b/src/libexpr/value-to-json.cc
@@ -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;
}
}