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

Unified Diff: lib/runtime/_operations.js

Issue 1233553005: Fixes #254 - Better stacktrace support (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Added utilities to help debugging 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 | lib/runtime/dart/_interceptors.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')
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 6f9294edfe6a23ecfbcd9e8454f66cec48ac1458..64f6b97bab6974f5232420a7ac9102540b24af3b 100644
--- a/lib/runtime/_operations.js
+++ b/lib/runtime/_operations.js
@@ -269,12 +269,28 @@ dart_library.library('dart_runtime/_operations', null, /* Imports */[
}
exports.assert = assert;
- function throw_(obj) { throw obj; }
- exports.throw_ = throw_;
+ let _stack = Symbol('_stack');
+ function throw_(obj) {
+ obj[_stack] = new Error();
+ throw obj;
+ }
+ exports.throw = throw_;
+
+ function getError(exception) {
+ return exception[_stack] ? exception[_stack] : exception;
+ }
+
+ // This is a utility function: it is only intended to be called from dev tools.
Jennifer Messerly 2015/07/14 18:30:33 long line. Maybe we need a module of debug utils?
+ function stackPrint(exception) {
+ var error = getError(exception);
+ console.log(error.stack ? error.stack : 'No stack trace for: ' + error);
Jennifer Messerly 2015/07/14 18:30:33 is this different from _js_helper.getTraceFromExce
+ }
+ exports.stackPrint = stackPrint;
function stackTrace(exception) {
- return _js_helper.getTraceFromException(exception);
+ var error = getError(exception);
+ return _js_helper.getTraceFromException(error);
}
exports.stackTrace = stackTrace;
« no previous file with comments | « no previous file | lib/runtime/dart/_interceptors.js » ('j') | lib/src/codegen/js_codegen.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698