Be more resilient to parse failures. (#1488)

In particular, "pub get --offline" and "pub cache repair" shouldn't
choke when there are parse failures in the version cache.

Closes #1479
diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart
index 2186cde..d85ed7f 100644
--- a/lib/src/pubspec.dart
+++ b/lib/src/pubspec.dart
@@ -427,7 +427,13 @@
   /// [Version.none].
   factory Pubspec.parse(String contents, SourceRegistry sources,
       {String expectedName, Uri location}) {
-    var pubspecNode = loadYamlNode(contents, sourceUrl: location);
+    YamlNode pubspecNode;
+    try {
+      pubspecNode = loadYamlNode(contents, sourceUrl: location);
+    } on YamlException catch (error) {
+      throw new PubspecException(error.message, error.span);
+    }
+
     Map pubspecMap;
     if (pubspecNode is YamlScalar && pubspecNode.value == null) {
       pubspecMap = new YamlMap(sourceUrl: location);