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

Unified Diff: lib/compiler/implementation/lib/js_helper.dart

Issue 10868069: Throw a runtime error when trying to call a constructor of a class that could not be resolved. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
Index: lib/compiler/implementation/lib/js_helper.dart
diff --git a/lib/compiler/implementation/lib/js_helper.dart b/lib/compiler/implementation/lib/js_helper.dart
index b969c9d4e621241ded0e0b8e6ca8b7b19023fd1e..e685ab1e46ce1d338531cbfb51869db2a83842df 100644
--- a/lib/compiler/implementation/lib/js_helper.dart
+++ b/lib/compiler/implementation/lib/js_helper.dart
@@ -764,16 +764,28 @@ makeLiteralListConst(list) {
return list;
}
+throwRuntimeError(message) {
+ var error = JS('var', @'new Error(#)', message);
+ JS('void', @'#.isDartRuntimeError = true', error);
+ JS('var', 'throw #', error);
+}
+
/**
* Called from catch blocks in generated code to extract the Dart
* exception from the thrown value. The thrown value may have been
- * created by [captureStackTrace] or it may be a 'native' JS
- * exception.
+ * created by [captureStackTrace], it may be a 'native' JS
+ * exception or it may be a Dart runtime error which is uncatchable.
ngeoffray 2012/08/24 15:43:48 Please check with the specification if that's the
karlklose 2012/08/28 09:09:15 Done, changed it to a normal throw.
*
* Some native exceptions are mapped to new Dart instances, others are
* returned unmodified.
*/
unwrapException(ex) {
+ // Check if this exception is a Dart runtime error. Runtime errors cannot
+ // be caught by generated code.
+ if (JS('bool', @'"isDartRuntimeError" in #', ex)) {
+ JS('void', @'throw #', ex);
+ }
+
// Note that we are checking if the object has the property. If it
// has, it could be set to null if the thrown value is null.
if (JS('bool', @'"dartException" in #', ex)) {
« no previous file with comments | « no previous file | lib/compiler/implementation/resolver.dart » ('j') | lib/compiler/implementation/ssa/builder.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698