mirror of
https://github.com/debug-js/debug.git
synced 2026-01-18 16:12:38 +00:00
Catch JSON stringily errors.
There is a chance that there may be circular references in the Object which will cause the debug message to throw an exception. If the exception is not handled on the application level this will cause node to crash. As a debug library, errors in here should not have such a serious impact on the application.
This commit is contained in:
parent
105497d62c
commit
6830d9fbee
@ -59,7 +59,11 @@ function useColors() {
|
||||
*/
|
||||
|
||||
exports.formatters.j = function(v) {
|
||||
return JSON.stringify(v);
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
}catch( err){
|
||||
return '[UnexpectedJSONParseError]: ' + err.message;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
6
dist/debug.js
vendored
6
dist/debug.js
vendored
@ -384,7 +384,11 @@ function useColors() {
|
||||
*/
|
||||
|
||||
exports.formatters.j = function(v) {
|
||||
return JSON.stringify(v);
|
||||
try {
|
||||
return JSON.stringify(v);
|
||||
}catch( err){
|
||||
return '[UnexpectedJSONParseError]: ' + err.message;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user