Chromium Code Reviews| 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)) { |