Index: pkg/yaml/lib/yaml.dart |
diff --git a/pkg/yaml/lib/yaml.dart b/pkg/yaml/lib/yaml.dart |
index dc895e655c60bf770ab7572664ed3a0b77b25c13..85a25df16e140b54104956e663fc66dfe42194db 100644 |
--- a/pkg/yaml/lib/yaml.dart |
+++ b/pkg/yaml/lib/yaml.dart |
@@ -25,8 +25,11 @@ export 'src/yaml_map.dart'; |
/// |
/// In future versions, maps will instead be [HashMap]s with a custom equality |
/// operation. |
-loadYaml(String yaml) { |
- var stream = loadYamlStream(yaml); |
+/// |
+/// [sourceName] is the name of the file or URL from which the YAML originated. |
+/// It's used for error reporting. |
Bob Nystrom
2014/05/30 16:32:39
I think it would be good to explicitly mention tha
nweiz
2014/06/02 18:36:14
Done.
|
+loadYaml(String yaml, {String sourceName}) { |
+ var stream = loadYamlStream(yaml, sourceName: sourceName); |
if (stream.length != 1) { |
throw new YamlException("Expected 1 document, were ${stream.length}."); |
} |
@@ -43,8 +46,18 @@ loadYaml(String yaml) { |
/// |
/// In future versions, maps will instead be [HashMap]s with a custom equality |
/// operation. |
-List loadYamlStream(String yaml) { |
- return new Parser(yaml).l_yamlStream() |
+/// |
+/// [sourceName] is the name of the file or URL from which the YAML originated. |
+/// It's used for error reporting. |
Bob Nystrom
2014/05/30 16:32:39
Here too.
nweiz
2014/06/02 18:36:14
Done.
|
+List loadYamlStream(String yaml, {String sourceName}) { |
+ var stream; |
+ try { |
+ stream = new Parser(yaml, sourceName).l_yamlStream(); |
+ } on FormatException catch (error) { |
+ throw new YamlException(error.toString()); |
+ } |
+ |
+ return stream |
.map((doc) => new Constructor(new Composer(doc).compose()).construct()) |
.toList(); |
} |