Permalink
Browse files

Fix stack trace capturing

R=skobes
DELTA=25  (25 added, 0 deleted, 0 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=4645


git-svn-id: http://closure-library.googlecode.com/svn/trunk@1789 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent 0c25aa3 commit 350b2f1d37f294b3c6e1797d1b983b68282506c7 nicksantos@google.com committed Apr 30, 2012
Showing with 25 additions and 0 deletions.
  1. +5 −0 closure/goog/debug/errorhandler.js
  2. +20 −0 closure/goog/debug/errorhandler_test.html
@@ -256,6 +256,11 @@ goog.debug.ErrorHandler.ProtectedFunctionError = function(cause) {
* @type {*}
*/
this.cause = cause;
+
+ var stack = cause && cause.stack;
+ if (stack) {
+ this.stack = stack;
+ }
};
goog.inherits(goog.debug.ErrorHandler.ProtectedFunctionError, goog.debug.Error);
@@ -163,6 +163,26 @@
assertEquals(fn, errorHandler.unwrap(wrappedFn));
}
+ function testStackPreserved() {
+ var e;
+ var hasStacks;
+ function specialFunctionName() {
+ var e = Error();
+ hasStacks = !!e.stack;
+ throw e;
+ };
+ var wrappedFn = errorHandler.wrap(specialFunctionName);
+ try {
+ wrappedFn();
+ } catch (exception) {
+ e = exception
+ }
+ assertTrue(!!e);
+ if (hasStacks) {
+ assertContains('specialFunctionName', e.stack);
+ }
+ }
+
function assertSetTimeoutError(caught) {
assertMethodCalledHelper('setTimeout', caught);
}

0 comments on commit 350b2f1

Please sign in to comment.