Factor error handling out with a lambda (note: Dart_LibraryImportLibrary's result was not checked until now!)