Skip to content

Commit 0b786c4

Browse files
committed
Addressed comments again
1 parent f73475b commit 0b786c4

File tree

4 files changed

+21
-13
lines changed

4 files changed

+21
-13
lines changed

packages/firebase_data_connect/firebase_data_connect/lib/src/common/dataconnect_error.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,22 @@ class DataConnectOperationFailureResponse<T> {
4848
class 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

6769
typedef Serializer<Variables> = String Function(Variables vars);

packages/firebase_data_connect/firebase_data_connect/lib/src/network/grpc_transport.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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();

packages/firebase_data_connect/firebase_data_connect/lib/src/network/rest_transport.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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();

packages/firebase_data_connect/firebase_data_connect/test/src/network/rest_transport_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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')),

0 commit comments

Comments
 (0)