-
Notifications
You must be signed in to change notification settings - Fork 5
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
Show upload fail error dialog #420
Conversation
var code: String { get } | ||
/// Error message that comes from the REST API. | ||
var message: String? { get } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the Gravatar backend, the errors have a standard format, a code and a message. The message is optional. So i think we can represent all the business errors with this protocol.
📲 You can test the changes from this Pull Request in Gravatar SwiftUI Prototype Build by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in Gravatar UIKit Prototype Build by scanning the QR code below to install the corresponding build.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do { | ||
let error: ModelError = try data.decode() | ||
return .invalidHTTPStatusCode(response: response, errorPayload: error) | ||
} catch { | ||
// if parsing the error fails then return invalidHTTPStatusCode without the payload. | ||
return .invalidHTTPStatusCode(response: response) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are skipping handling the parsing error, maybe we can avoid using try-catch?
do { | |
let error: ModelError = try data.decode() | |
return .invalidHTTPStatusCode(response: response, errorPayload: error) | |
} catch { | |
// if parsing the error fails then return invalidHTTPStatusCode without the payload. | |
return .invalidHTTPStatusCode(response: response) | |
} | |
let error: ModelError? = try? data.decode() | |
return .invalidHTTPStatusCode(response: response, errorPayload: error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. 👍
Hmm now that you pointed out I feel like it shouldn't. I'll remove the |
Closes #373
Description
Adds upload fail dialog.
Some errors are not suitable for retrying, so we don't show the retry option for them. These are the HTTP 400 errors for now. We know from REST API specs that these are validation errors about the image. Maybe we should make this assumption for all 4XX errors. I feel like it is better to show the Retry option in a false positive situation than not show it when it is actually needed.
Others look like this:
Testing Steps
SwiftUI demo app > Avatar Picker View
(It is a bit difficult to generate HTTP 400 errors, i had to comment out some image cropping code to get that not-square error ☝️. )