Skip to content

Commit 365630e

Browse files
committed
fix(toJson): suppress toJson exceptions in core functions that prepare error messages for user
Makes use of suppressExceptions option parameter in toJson function. Closes angular#9838
1 parent 1f966a0 commit 365630e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/minErr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function minErr(module, ErrorConstructor) {
5959
} else if (typeof arg === 'undefined') {
6060
return 'undefined';
6161
} else if (typeof arg !== 'string') {
62-
return toJson(arg);
62+
return toJson(arg, false, {suppressExceptions: true});
6363
}
6464
return arg;
6565
}

src/ng/directive/ngRepeat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
366366
});
367367
throw ngRepeatMinErr('dupes',
368368
"Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}, Duplicate value: {2}",
369-
expression, trackById, toJson(value));
369+
expression, trackById, toJson(value, false, {suppressExceptions: true}));
370370
} else {
371371
// new never before seen block
372372
nextBlockOrder[index] = {id: trackById, scope: undefined, clone: undefined};

src/ng/rootScope.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,8 @@ function $RootScopeProvider() {
776776
logMsg = (isFunction(watch.exp))
777777
? 'fn: ' + (watch.exp.name || watch.exp.toString())
778778
: watch.exp;
779-
logMsg += '; newVal: ' + toJson(value) + '; oldVal: ' + toJson(last);
779+
logMsg += '; newVal: ' + toJson(value, false, {suppressExceptions: true}) +
780+
'; oldVal: ' + toJson(last, false, {suppressExceptions: true});
780781
watchLog[logIdx].push(logMsg);
781782
}
782783
} else if (watch === lastDirtyWatch) {
@@ -810,7 +811,7 @@ function $RootScopeProvider() {
810811
throw $rootScopeMinErr('infdig',
811812
'{0} $digest() iterations reached. Aborting!\n' +
812813
'Watchers fired in the last 5 iterations: {1}',
813-
TTL, toJson(watchLog));
814+
TTL, toJson(watchLog, false, {suppressExceptions: true}));
814815
}
815816

816817
} while (dirty || asyncQueue.length);

0 commit comments

Comments
 (0)