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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 2044753002: Make compile-time errors catchable (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments Created 4 years, 3 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 | « runtime/vm/compiler.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index ccda7f0d172d6666140b1b55016e06ce5106d367..f850c99dca0f0d210e1f1e2f224ccc32310ba51c 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -184,6 +184,15 @@ static RawInstance* GetMapInstance(Zone* zone, const Object& obj) {
}
+static bool IsCompiletimeErrorObject(Zone* zone, const Object& obj) {
+ Isolate* I = Thread::Current()->isolate();
+ const Class& error_class =
+ Class::Handle(zone, I->object_store()->compiletime_error_class());
+ ASSERT(!error_class.IsNull());
+ return (obj.GetClassId() == error_class.id());
+}
+
+
static bool GetNativeStringArgument(NativeArguments* arguments,
int arg_index,
Dart_Handle* str,
@@ -761,6 +770,13 @@ DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) {
DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) {
+ if (Dart_IsUnhandledExceptionError(object)) {
+ DARTSCOPE(Thread::Current());
+ const UnhandledException& error =
+ UnhandledException::Cast(Object::Handle(Z, Api::UnwrapHandle(object)));
+ const Instance& exc = Instance::Handle(Z, error.exception());
+ return IsCompiletimeErrorObject(Z, exc);
+ }
return Api::ClassId(object) == kLanguageErrorCid;
}
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698