Skip to content

Commit 3491ad6

Browse files
Merge pull request #195 from jalleyne/master
Catch JSON stringily errors.
2 parents 2caf4ef + 6830d9f commit 3491ad6

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

browser.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ function useColors() {
5353
*/
5454

5555
exports.formatters.j = function(v) {
56-
return JSON.stringify(v);
56+
try {
57+
return JSON.stringify(v);
58+
}catch( err){
59+
return '[UnexpectedJSONParseError]: ' + err.message;
60+
}
5761
};
5862

5963

dist/debug.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,11 @@ function useColors() {
379379
*/
380380

381381
exports.formatters.j = function(v) {
382-
return JSON.stringify(v);
382+
try {
383+
return JSON.stringify(v);
384+
}catch( err){
385+
return '[UnexpectedJSONParseError]: ' + err.message;
386+
}
383387
};
384388

385389

0 commit comments

Comments
 (0)