Skip to content

Commit 109ca07

Browse files
authored
feat(sidekick/swift): use rpc() helper (#6217)
Use the `GoogleCloudGax.HTTPClient.rpc()` as it captures service errors with full details. Arguably the generated code is a little shorter too, which is not a bad thing.
1 parent d33029a commit 109ca07

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

internal/sidekick/swift/templates/common/stub.swift.mustache

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,14 @@ extension Clients {
8282
}
8383
{{/Codec.IsBodyWildcard}}
8484
{{/Codec.HasBody}}
85-
let (data, response) = try await self.inner.data(for: req)
86-
if !(200..<300).contains(response.statusCode) {
87-
throw GoogleCloudGax.RequestError.http(GoogleCloudGax.HTTPDetails(
88-
http_status_code: response.statusCode,
89-
headers: [:],
90-
payload: data,
91-
))
92-
}
9385
{{^ReturnsEmpty}}
86+
let (data, _) = try await self.inner.rpc(for: req).get()
9487
return try {{InputType.Codec.Model.WktPackage}}._ProtoJSONDecoder().decode(
9588
{{Codec.ReturnType}}.self, from: data)
9689
{{/ReturnsEmpty}}
90+
{{#ReturnsEmpty}}
91+
_ = try await self.inner.rpc(for: req).get()
92+
{{/ReturnsEmpty}}
9793
}
9894
{{/Codec.RestMethods}}
9995
}

0 commit comments

Comments
 (0)