Skip to content

Commit 6b8efd4

Browse files
committed
remove explicit construction
The promise usage left some to be desired and I felt like I should help by refactoring out [explicit construction](http://stackoverflow.com/questions/23803743/what-is-the-explicit-promise-construction-antipattern-and-how-do-i-avoid-it/23803744#23803744) which I used to do myself when I started with promises. Thanks for the library.
1 parent b4077c1 commit 6b8efd4

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

stacktrace.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,15 @@
8080
fromError: function StackTrace$$fromError(error, opts) {
8181
opts = _merge(_options, opts);
8282
var gps = new StackTraceGPS(opts);
83-
return new Promise(function(resolve) {
84-
var stackframes = ErrorStackParser.parse(error);
85-
if (typeof opts.filter === 'function') {
86-
stackframes = stackframes.filter(opts.filter);
87-
}
88-
resolve(Promise.all(stackframes.map(function(sf) {
89-
return new Promise(function(resolve) {
90-
function resolveOriginal() {
91-
resolve(sf);
92-
}
93-
94-
gps.pinpoint(sf).then(resolve, resolveOriginal)['catch'](resolveOriginal);
95-
});
96-
})));
97-
}.bind(this));
83+
var stackframes = ErrorStackParser.parse(error);
84+
if (typeof opts.filter === 'function') {
85+
stackframes = stackframes.filter(opts.filter);
86+
}
87+
return Promise.all(stackframes.map(function(sf) {
88+
return gps.pinpoint(sf);
89+
}).catch(function(error) {
90+
return sf;
91+
}));
9892
},
9993

10094
/**

0 commit comments

Comments
 (0)