google-api-swift-client
google-api-swift-client copied to clipboard
Improve error handling by using Result<Z, Error> instead of (Z?, Error?)
- Also properly decode errors when HTTP status code is greater or equal to 400
- Make all
Service.perfom()
functions non throwing and return the error through the completion handler if applicable instead
After merging and attempting to resolve conflicts, I found a few build errors like the ones below.
It seems to me that this is because we didn't remove throwing from the performRequest methods in google-auth-library-swift. @0xced did you do that in a separate branch/repo? I would support merging that.
$ make
swift build -c debug
/Users/timburks/Desktop/google-api-swift-client/Sources/GoogleAPIRuntime/Service.swift:152:5: error: call can throw, but it is not marked with 'try' and the error is not handled
connection.performRequest(
^
/Users/timburks/Desktop/google-api-swift-client/Sources/GoogleAPIRuntime/Service.swift:169:7: error: call can throw but is not marked with 'try'
connection.performRequest(
^~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/timburks/Desktop/google-api-swift-client/Sources/GoogleAPIRuntime/Service.swift:169:7: note: did you mean to use 'try'?
connection.performRequest(
^
try
/Users/timburks/Desktop/google-api-swift-client/Sources/GoogleAPIRuntime/Service.swift:169:7: note: did you mean to handle error as optional value?
connection.performRequest(
^
try?
I have several work in progress branches in both google-auth-library-swift
and google-api-swift-client
. I will rebase them all, fix the errors and submit new pull requests.