@@ -36,7 +36,6 @@ T checkedYamlDecode<T>(
36
36
if (yaml is YamlMap ) {
37
37
map = yaml;
38
38
} else if (allowNull && yaml is YamlScalar && yaml.value == null ) {
39
- // TODO: test this case!
40
39
map = null ;
41
40
} else {
42
41
throw ParsedYamlException ('Not a map' , yaml);
@@ -73,34 +72,29 @@ ParsedYamlException toParsedYamlException(
73
72
)
74
73
as YamlNode ;
75
74
return ParsedYamlException (exception.message! , node, innerError: exception);
76
- } else {
77
- if (exception.key == null ) {
78
- return ParsedYamlException (
79
- exception.message ?? 'There was an error parsing the map.' ,
80
- yamlMap,
81
- innerError: exception,
82
- );
83
- } else if (! yamlMap.containsKey (exception.key)) {
84
- return ParsedYamlException (
85
- [
86
- 'Missing key "${exception .key }".' ,
87
- if (exception.message != null ) exception.message! ,
88
- ].join (' ' ),
89
- yamlMap,
90
- innerError: exception,
91
- );
92
- } else {
93
- var message = 'Unsupported value for "${exception .key }".' ;
94
- if (exception.message != null ) {
95
- message = '$message ${exception .message }' ;
96
- }
97
- return ParsedYamlException (
98
- message,
99
- yamlMap.nodes[exception.key] ?? yamlMap,
100
- innerError: exception,
101
- );
102
- }
103
75
}
76
+
77
+ if (exception.key == null ) {
78
+ return ParsedYamlException (
79
+ exception.message ?? 'There was an error parsing the map.' ,
80
+ yamlMap,
81
+ innerError: exception,
82
+ );
83
+ }
84
+
85
+ if (! yamlMap.containsKey (exception.key)) {
86
+ return ParsedYamlException (
87
+ ['Missing key "${exception .key }".' , ? exception.message].join (' ' ),
88
+ yamlMap,
89
+ innerError: exception,
90
+ );
91
+ }
92
+
93
+ return ParsedYamlException (
94
+ ['Unsupported value for "${exception .key }".' , ? exception.message].join (' ' ),
95
+ yamlMap.nodes[exception.key] ?? yamlMap,
96
+ innerError: exception,
97
+ );
104
98
}
105
99
106
100
/// An exception thrown when parsing YAML that contains information about the
@@ -118,12 +112,10 @@ class ParsedYamlException implements Exception {
118
112
/// contains the source error object.
119
113
final Object ? innerError;
120
114
121
- ParsedYamlException (String message, YamlNode this .yamlNode, {this .innerError})
122
- : // TODO(kevmoo) remove when dart-lang/sdk#50756 is fixed!
123
- message = message.replaceAll (" of ' in type cast'" , ' in type cast' );
115
+ ParsedYamlException (this .message, YamlNode this .yamlNode, {this .innerError});
124
116
125
- factory ParsedYamlException .fromYamlException (YamlException exception) =>
126
- _WrappedYamlException (exception) ;
117
+ factory ParsedYamlException .fromYamlException (YamlException exception) =
118
+ _WrappedYamlException ;
127
119
128
120
/// Returns [message] formatted with source information provided by
129
121
/// [yamlNode] .
@@ -147,7 +139,4 @@ class _WrappedYamlException implements ParsedYamlException {
147
139
148
140
@override
149
141
YamlNode ? get yamlNode => null ;
150
-
151
- @override
152
- String toString () => 'ParsedYamlException: $formattedMessage ' ;
153
142
}
0 commit comments