Chromium Code Reviews| Index: lib/runtime/_operations.js |
| diff --git a/lib/runtime/_operations.js b/lib/runtime/_operations.js |
| index 4d964b441b8f3200e9d220d7d93ae5daffec1033..822054efbb0a3632ab7fd5f3059cd27a51ab6832 100644 |
| --- a/lib/runtime/_operations.js |
| +++ b/lib/runtime/_operations.js |
| @@ -269,16 +269,21 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[ |
| } |
| exports.assert = assert; |
| - let _stack = Symbol('_stack'); |
| - |
| + let _stack = new WeakMap(); |
| function throw_(obj) { |
| - obj[_stack] = new Error(); |
| + if (obj != null && (typeof obj == 'object' || typeof obj == 'function')) { |
| + // TODO(jmesserly): couldn't we store the most recent stack in a single |
| + // variable? There should only be one active stack trace. That would |
| + // allow it to work for things like strings and numbers. |
|
vsm
2015/07/23 14:00:04
I don't think we want this in the general case. I
Jennifer Messerly
2015/07/23 15:51:30
Sure, but they should be wrapping the stack trace
|
| + _stack.set(obj, new Error()); |
| + } |
| throw obj; |
| } |
| exports.throw = throw_; |
| function getError(exception) { |
| - return exception[_stack] ? exception[_stack] : exception; |
| + var stack = _stack.get(exception); |
| + return stack !== void 0 ? stack : exception; |
| } |
| // This is a utility function: it is only intended to be called from dev |