File tree Expand file tree Collapse file tree 4 files changed +21
-13
lines changed
packages/firebase_data_connect/firebase_data_connect Expand file tree Collapse file tree 4 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -48,20 +48,22 @@ class DataConnectOperationFailureResponse<T> {
4848class DataConnectOperationFailureResponseErrorInfo {
4949 DataConnectOperationFailureResponseErrorInfo (this .path, this .message);
5050 String message;
51- List <PathSegment > path;
51+ List <DataConnectOperationFailureErrorInfoPathSegment > path;
5252}
5353
5454/// Path where error occurred.
55- sealed class PathSegment {}
55+ sealed class DataConnectOperationFailureErrorInfoPathSegment {}
5656
57- class StringValue extends PathSegment {
58- final String value;
59- StringValue (this .value);
57+ class DataConnectOperationFailureErrorInfoFieldPathSegment
58+ extends DataConnectOperationFailureErrorInfoPathSegment {
59+ final String field;
60+ DataConnectOperationFailureErrorInfoFieldPathSegment (this .field);
6061}
6162
62- class IntValue extends PathSegment {
63- final int value;
64- IntValue (this .value);
63+ class DataConnectOperationFailureErrorInfoListIndexPathSegment
64+ extends DataConnectOperationFailureErrorInfoPathSegment {
65+ final int index;
66+ DataConnectOperationFailureErrorInfoListIndexPathSegment (this .index);
6567}
6668
6769typedef Serializer <Variables > = String Function (Variables vars);
Original file line number Diff line number Diff line change @@ -180,8 +180,10 @@ Data handleResponse<Data>(CommonResponse<Data> commonResponse) {
180180 .map ((e) => DataConnectOperationFailureResponseErrorInfo (
181181 e.path.values
182182 .map ((val) => val.hasStringValue ()
183- ? StringValue (val.stringValue)
184- : IntValue (val.numberValue.toInt ()))
183+ ? DataConnectOperationFailureErrorInfoFieldPathSegment (
184+ val.stringValue)
185+ : DataConnectOperationFailureErrorInfoListIndexPathSegment (
186+ val.numberValue.toInt ()))
185187 .toList (),
186188 e.message))
187189 .toList ();
Original file line number Diff line number Diff line change @@ -150,8 +150,10 @@ class RestTransport implements DataConnectTransport {
150150 .map ((e) => DataConnectOperationFailureResponseErrorInfo (
151151 (e['path' ] as List )
152152 .map ((val) => val.runtimeType == String
153- ? StringValue (val)
154- : IntValue (val))
153+ ? DataConnectOperationFailureErrorInfoFieldPathSegment (
154+ val)
155+ : DataConnectOperationFailureErrorInfoListIndexPathSegment (
156+ val))
155157 .toList (),
156158 e['message' ]))
157159 .toList ();
Original file line number Diff line number Diff line change @@ -422,7 +422,9 @@ void main() {
422422 e.response.data! ['abc' ] == 'def' &&
423423 e.response.errors.first.message ==
424424 'SQL query error: pq: duplicate key value violates unique constraint movie_pkey' &&
425- (e.response.errors.first.path[0 ] as StringValue ).value ==
425+ (e.response.errors.first.path[0 ]
426+ as DataConnectOperationFailureErrorInfoFieldPathSegment )
427+ .field ==
426428 'the_matrix' &&
427429 e.response.decodedData is AbcHolder &&
428430 (e.response.decodedData as AbcHolder ).abc == 'def' )),
You can’t perform that action at this time.
0 commit comments