Skip to content

Commit 3f277ce

Browse files
committed
DataConnectError.swift: minor tweaks from offline discussion
1 parent d5b1f19 commit 3f277ce

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

Sources/DataConnectError.swift

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public enum DataConnectError: Error {
2424
case grpcNotConfigured
2525

2626
/// failed to decode results from server
27-
case decodeFailed(response: AnyDataConnectOperationResponse)
27+
case decodeFailed(message: String, response: AnyOperationFailureResponse)
2828

2929
/// Invalid uuid format during encoding / decoding of data
3030
case invalidUUID
@@ -36,37 +36,36 @@ public enum DataConnectError: Error {
3636
case invalidTimestampFormat
3737

3838
/// generic operation execution error
39-
case operationExecutionFailed(response: AnyDataConnectOperationResponse)
39+
case operationExecutionFailed(message: String, response: AnyOperationFailureResponse)
4040
}
4141

4242
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
43-
public protocol AnyDataConnectOperationResponse {
43+
public protocol AnyOperationFailureResponse {
4444
// JSON string
4545
var data: String? { get }
4646

47-
var errors: [DataConnectOperationErrorInfo] { get }
47+
var errors: [OperationFailureResponse.ErrorInfo] { get }
4848
}
4949

5050
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
51-
public struct DataConnectOperationResponse<T> : AnyDataConnectOperationResponse {
51+
public struct OperationFailureResponse<T> : AnyOperationFailureResponse {
5252
// JSON string
5353
public let data: String?
5454

55-
public let errors: [DataConnectOperationErrorInfo]
55+
public let errors: [ErrorInfo]
5656

5757
public let decodedData: T?
58-
}
59-
60-
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
61-
public struct DataConnectOperationErrorInfo: Codable {
62-
public let message: String
63-
public let path: [PathSegment]
6458

6559
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
66-
public enum PathSegment: Codable {
67-
case field(String)
68-
case listIndex(Int)
69-
}
60+
public struct ErrorInfo: Codable {
61+
public let message: String
62+
public let path: [PathSegment]
7063

71-
}
64+
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
65+
public enum PathSegment: Codable {
66+
case field(String)
67+
case listIndex(Int)
68+
}
7269

70+
}
71+
}

0 commit comments

Comments
 (0)