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

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: wip 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
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..7e3a401d285fc558e4b5ccad1c496633b9967c29 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -184,6 +184,18 @@ static RawInstance* GetMapInstance(Zone* zone, const Object& obj) {
}
+static bool IsSyntaxErrorObject(Zone* zone, const Object& obj) {
+ Isolate* I = Thread::Current()->isolate();
+ const Class& error_class =
+ Class::Handle(I->object_store()->syntax_error_class());
siva 2016/09/15 18:11:45 Handle(zone, I->object_store().... as the zone see
hausner 2016/09/15 21:28:28 Done.
+ ASSERT(!error_class.IsNull());
+ if (obj.GetClassId() == error_class.id()) {
+ return true;
+ }
+ return false;
+}
+
+
static bool GetNativeStringArgument(NativeArguments* arguments,
int arg_index,
Dart_Handle* str,
@@ -761,6 +773,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 IsSyntaxErrorObject(Z, exc);
+ }
return Api::ClassId(object) == kLanguageErrorCid;
}

Powered by Google App Engine
This is Rietveld 408576698