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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1663613002: Dart_SetReturnValue now accepts and propagates error handles. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code review Created 4 years, 11 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/dart_api_impl.h ('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 43d308eb52fae79ee2c5bb23c9905d7760d5a1c4..192a86616f27b485b8d954f6d0b0aef6211af6ba 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -733,7 +733,7 @@ void FinalizablePersistentHandle::Finalize(
// --- Handles ---
DART_EXPORT bool Dart_IsError(Dart_Handle handle) {
- return RawObject::IsErrorClassId(Api::ClassId(handle));
+ return Api::IsError(handle);
}
@@ -4410,6 +4410,10 @@ DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception) {
Isolate* isolate = thread->isolate();
CHECK_ISOLATE(isolate);
CHECK_CALLBACK_STATE(thread);
+ if (Api::IsError(exception)) {
+ Dart_PropagateError(exception);
+ }
+
{
const Instance& excp = Api::UnwrapInstanceHandle(zone, exception);
if (excp.IsNull()) {
@@ -4833,15 +4837,17 @@ DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
Dart_Handle retval) {
NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
ASSERT(arguments->thread()->isolate() == Isolate::Current());
- if ((retval != Api::Null()) && (!Api::IsInstance(retval))) {
+ if ((retval != Api::Null()) &&
+ !Api::IsInstance(retval) &&
+ !Api::IsError(retval)) {
// Print the current stack trace to make the problematic caller
// easier to find.
const Stacktrace& stacktrace = GetCurrentStacktrace(0);
OS::PrintErr("=== Current Trace:\n%s===\n", stacktrace.ToCString());
const Object& ret_obj = Object::Handle(Api::UnwrapHandle(retval));
- FATAL1("Return value check failed: saw '%s' expected a dart Instance.",
- ret_obj.ToCString());
+ FATAL1("Return value check failed: saw '%s' expected a dart Instance or "
+ "an Error.", ret_obj.ToCString());
}
ASSERT(retval != 0);
Api::SetReturnValue(arguments, retval);
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698