src: don't print garbage errors · nodejs/node@da3137d · GitHub
Skip to content

Commit da3137d

Browse files
cjihrigrvagg
authored andcommitted
src: don't print garbage errors
If JS throws an object whose toString() method throws, then Node attempts to print an empty message, but actually prints garbage. This commit checks for this case, and prints a message instead. Fixes: #4079 PR-URL: #4112 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
1 parent 1d50819 commit da3137d

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

src/node.cc

Lines changed: 4 additions & 2 deletions

test/fixtures/throws_error7.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
throw {
2+
toString: function() {
3+
throw this;
4+
}
5+
};

test/parallel/test-error-reporting.js

Lines changed: 6 additions & 3 deletions

0 commit comments

Comments
 (0)