Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: lib/runtime/_operations.js

Issue 1245023004: fixes dart.throw to work for non-objects (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/browser/runtime_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | test/browser/runtime_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698