Skip to content

Commit 4f7b1e5

Browse files
Throw error if partial errors are detected
1 parent b44db4e commit 4f7b1e5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Sources/DataConnectError.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ public enum DataConnectError: Error {
3434

3535
/// timestamp components specified to initialize Timestamp are invalid
3636
case invalidTimestampFormat
37+
38+
/// generic operation execution error
39+
case operationExecutionFailed
40+
3741
}

Sources/Internal/GrpcClient.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ actor GrpcClient: CustomStringConvertible {
148148
let resultsString = try results.jsonString()
149149
DataConnectLogger
150150
.debug("executeQuery() receives response: \(resultsString, privacy: .private).")
151+
151152
// Not doing error decoding here
153+
guard results.errors.isEmpty else {
154+
throw DataConnectError.operationExecutionFailed
155+
}
156+
152157
if let decodedResults = try codec.decode(result: results.data, asType: resultType) {
153158
return OperationResult(data: decodedResults)
154159
} else {
@@ -191,6 +196,11 @@ actor GrpcClient: CustomStringConvertible {
191196
let resultsString = try results.jsonString()
192197
DataConnectLogger
193198
.debug("executeMutation() receives response: \(resultsString, privacy: .private).")
199+
200+
guard results.errors.isEmpty else {
201+
throw DataConnectError.operationExecutionFailed
202+
}
203+
194204
if let decodedResults = try codec.decode(result: results.data, asType: resultType) {
195205
return OperationResult(data: decodedResults)
196206
} else {

0 commit comments

Comments
 (0)