Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Error.captureStackTrace where available in goog.debug.Error

MOE import of r1696 by Dan Pupius

Revision created by MOE tool push_codebase.

R=chrishenry
DELTA=20  (14 added, 0 deleted, 6 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=4447


git-svn-id: http://closure-library.googlecode.com/svn/trunk@1698 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
commit 1a163cc4f09c5133cc12e9ff2154332de7bb998b 1 parent d3dd0dc
nicksantos@google.com authored
View
2  AUTHORS
@@ -13,3 +13,5 @@ Ilia Mirkin <ibmirkin@gmail.com>
Ivan Kozik <ivan.kozik@gmail.com>
Rich Dougherty <rich@rd.gen.nz>
Chad Killingsworth <chadkillingsworth@missouristate.edu>
+Dan Pupius <dan.pupius@gmail.com>
+
View
6 closure/goog/debug/error.js
@@ -34,7 +34,11 @@ goog.provide('goog.debug.Error');
goog.debug.Error = function(opt_msg) {
// Ensure there is a stack trace.
- this.stack = new Error().stack || '';
+ if (Error.captureStackTrace) {
+ Error.captureStackTrace(this, goog.debug.Error);
+ } else {
+ this.stack = new Error().stack || '';
+ }
if (opt_msg) {
this.message = String(opt_msg);
View
18 closure/goog/debug/error_test.html
@@ -62,11 +62,19 @@
stack.splice(0, 0, 'Error');
}
- assertContains('1st line of stack should have "Error"', 'Error', stack[0]);
- // 2nd line is slightly different in firefox/chrome
- assertContains('3rd line of stack should have "zzzzz"', 'zzzzz', stack[2]);
- assertContains('4th line of stack should have "yyyyy"', 'yyyyy', stack[3]);
- assertContains('5th line of stack should have "xxxxx"', 'xxxxx', stack[4]);
+ if (Error.captureStackTrace) {
+ // captureStackTrace removes extra junk.
+ assertContains('1st line of stack should have "Error"', 'Error', stack[0]);
+ assertContains('2nd line of stack should have "zzzzz"', 'zzzzz', stack[1]);
+ assertContains('3rd line of stack should have "yyyyy"', 'yyyyy', stack[2]);
+ assertContains('4th line of stack should have "xxxxx"', 'xxxxx', stack[3]);
+ } else {
+ assertContains('1st line of stack should have "Error"', 'Error', stack[0]);
+ // 2nd line is slightly different in firefox/chrome
+ assertContains('3rd line of stack should have "zzzzz"', 'zzzzz', stack[2]);
+ assertContains('4th line of stack should have "yyyyy"', 'yyyyy', stack[3]);
+ assertContains('5th line of stack should have "xxxxx"', 'xxxxx', stack[4]);
+ }
} catch (e) {
expectedFailures.handleException(e);
}
Please sign in to comment.
Something went wrong with that request. Please try again.