Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse JSON error response #186

Merged
merged 3 commits into from
Jul 29, 2022
Merged

Parse JSON error response #186

merged 3 commits into from
Jul 29, 2022

Conversation

AvdLee
Copy link
Owner

@AvdLee AvdLee commented Jul 29, 2022

Allowing users to parse the returned error response and catch it:

do {
    print(try await self.provider.request(requestWithError).data)
} catch APIProvider.Error.requestFailure(let statusCode, let errorResponse, _) {
    print("Request failed with statuscode: \(statusCode) and the following errors:")
    errorResponse?.errors?.forEach({ error in
        print("Error code: \(error.code)")
        print("Error title: \(error.title)")
        print("Error detail: \(error.detail)")
    })
} catch {
    print("Something went wrong fetching the apps: \(error.localizedDescription)")
}

This PR also changed how errors are printed:

Request https://api.appstoreconnect.apple.com failed with status code 404. Related response error(s):

The request failed with response code 404 NOT_FOUND

The specified resource does not exist. There is no resource of type 'builds' with id 'app.appId').

@AvdLee AvdLee self-assigned this Jul 29, 2022
@AvdLee AvdLee merged commit ed790a6 into master Jul 29, 2022
@AvdLee AvdLee deleted the feature/better-errors branch July 29, 2022 15:48
@SwiftLeeBot
Copy link
Collaborator

Congratulations! 🎉 This was released as part of Release 2.1.0 🚀

Generated by GitBuddy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants