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

Unified Diff: runtime/lib/mirrors_patch.dart

Issue 287523003: Improve error messages in MirrorSystem.findLibrary. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/mirrors_patch.dart
diff --git a/runtime/lib/mirrors_patch.dart b/runtime/lib/mirrors_patch.dart
index 12cbd56915953763ab13a5716bd2b8d220f32ea1..1534e796d6d3e41b4952784e2b03d765e9730f09 100644
--- a/runtime/lib/mirrors_patch.dart
+++ b/runtime/lib/mirrors_patch.dart
@@ -36,6 +36,20 @@ patch TypeMirror reflectType(Type key) {
}
patch class MirrorSystem {
+ /* patch */ LibraryMirror findLibrary(Symbol libraryName) {
+ var candidates =
+ libraries.values.where((lib) => lib.simpleName == libraryName);
+ if (candidates.length == 1) {
+ return candidates.single;
+ }
+ if (candidates.length > 1) {
+ var uris = candidates.map((lib) => lib.uri.toString()).toList();
+ throw new Exception("There are multiple libraries named "
+ "'${getName(libraryName)}': $uris");
+ }
+ throw new Exception("There is no library named '${getName(libraryName)}'");
+ }
+
/* patch */ static String getName(Symbol symbol) {
String string = _symbol_dev.Symbol.getName(symbol);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698