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

Unified Diff: pkg/analyzer/lib/source/analysis_options_provider.dart

Issue 1415153004: Improved YAML doc exception handling. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | pkg/analyzer/test/source/analysis_options_provider_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/source/analysis_options_provider.dart
diff --git a/pkg/analyzer/lib/source/analysis_options_provider.dart b/pkg/analyzer/lib/source/analysis_options_provider.dart
index 29062a26a41de8dbc6aa34f3471f16d98ad893a7..529e52f36539d7be4bba5aacb3d9af5fa50bdacd 100644
--- a/pkg/analyzer/lib/source/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
@@ -33,7 +33,16 @@ class AnalysisOptionsProvider {
if (optionsSource == null) {
return options;
}
- YamlNode doc = loadYamlNode(optionsSource);
+
+ YamlNode doc;
+ try {
+ doc = loadYamlNode(optionsSource);
+ } on YamlException catch (e) {
+ throw new OptionsFormatException(e.message, e.span);
+ } catch (e) {
+ throw new OptionsFormatException('Unable to parse YAML document.');
+ }
+
// Empty options.
if (doc is YamlScalar && doc.value == null) {
return options;
@@ -44,7 +53,7 @@ class AnalysisOptionsProvider {
doc.span);
}
if (doc is YamlMap) {
- doc.forEach((k, v) {
+ (doc as YamlMap).forEach((k, v) {
if (k is! String) {
throw new OptionsFormatException(
'Bad options file format (expected String scope key, '
« no previous file with comments | « no previous file | pkg/analyzer/test/source/analysis_options_provider_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698