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

Unified Diff: runtime/lib/mirrors.cc

Issue 20458002: Wrap lazy compilation errors when parsing metadata. Addresses the poor error reporting in issue 120… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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/lib/mirrors.cc
===================================================================
--- runtime/lib/mirrors.cc (revision 25492)
+++ runtime/lib/mirrors.cc (working copy)
@@ -981,6 +981,28 @@
}
+static void ThrowMirroredCompilationError(const String& message) {
+ Array& args = Array::Handle(Array::New(1));
+ args.SetAt(0, message);
+
+ Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args);
+ UNREACHABLE();
+}
+
+
+static void ThrowInvokeError(const Error& error) {
+ if (error.IsLanguageError()) {
+ // A compilation error that was delayed by lazy compilation.
+ const LanguageError& compilation_error = LanguageError::Cast(error);
+ String& message = String::Handle(compilation_error.message());
+ ThrowMirroredCompilationError(message);
+ UNREACHABLE();
+ }
+ Exceptions::PropagateError(error);
+ UNREACHABLE();
+}
+
+
DEFINE_NATIVE_ENTRY(DeclarationMirror_metadata, 1) {
const MirrorReference& decl_ref =
MirrorReference::CheckedHandle(arguments->NativeArgAt(0));
@@ -998,7 +1020,11 @@
}
const Library& library = Library::Handle(klass.library());
- return library.GetMetadata(decl);
+ const Object& metadata = Object::Handle(library.GetMetadata(decl));
+ if (metadata.IsError()) {
+ ThrowInvokeError(Error::Cast(metadata));
+ }
+ return metadata.raw();
}
@@ -1009,28 +1035,6 @@
}
-static void ThrowMirroredCompilationError(const String& message) {
- Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, message);
-
- Exceptions::ThrowByType(Exceptions::kMirroredCompilationError, args);
- UNREACHABLE();
-}
-
-
-static void ThrowInvokeError(const Error& error) {
- if (error.IsLanguageError()) {
- // A compilation error that was delayed by lazy compilation.
- const LanguageError& compilation_error = LanguageError::Cast(error);
- String& message = String::Handle(compilation_error.message());
- ThrowMirroredCompilationError(message);
- UNREACHABLE();
- }
- Exceptions::PropagateError(error);
- UNREACHABLE();
-}
-
-
static bool FieldIsUninitialized(const Field& field) {
ASSERT(!field.IsNull());

Powered by Google App Engine
This is Rietveld 408576698