Skip to content

Commit b348347

Browse files
committed
refactor(fromJson): Remove error() and just throw
It's more likely you are using angular.fromJson() inside Angular world, which means you get proper exception handling by $exceptionHandler. There is no point to explicitly push it to console and it causes memory leaks on most browsers (tried Chrome stable/canary, Safari, FF).
1 parent 512db03 commit b348347

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/Angular.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ var $boolean = 'boolean',
8383
slice = [].slice,
8484
push = [].push,
8585
toString = Object.prototype.toString,
86-
error = window[$console]
87-
? bind(window[$console], window[$console]['error'] || noop)
88-
: noop,
8986

9087
/** @name angular */
9188
angular = window.angular || (window.angular = {}),

src/JSON.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,12 @@ function fromJson(json, useNative) {
3737

3838
var obj;
3939

40-
try {
41-
if (useNative && window.JSON && window.JSON.parse) {
42-
obj = JSON.parse(json);
43-
} else {
44-
obj = parseJson(json, true)();
45-
}
46-
return transformDates(obj);
47-
} catch (e) {
48-
error("fromJson error: ", json, e);
49-
throw e;
40+
if (useNative && window.JSON && window.JSON.parse) {
41+
obj = JSON.parse(json);
42+
} else {
43+
obj = parseJson(json, true)();
5044
}
45+
return transformDates(obj);
5146

5247
// TODO make forEach optionally recursive and remove this function
5348
// TODO(misko): remove this once the $http service is checked in.

0 commit comments

Comments
 (0)