mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 08:49:52 +00:00
Improve error messages in MirrorSystem.findLibrary.
BUG=http://dartbug.com/18532 R=gbracha@google.com Review URL: https://codereview.chromium.org//287523003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@36114 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
06d1ca8545
commit
3939e3e7f5
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue