-
Notifications
You must be signed in to change notification settings - Fork 85
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
Use optional initializers instead of throw #71
Comments
Hi @sebastianludwig , can you be a bit more explicit in your issue of which errors are being thrown and why this is problematic? To say this is "bad style" is a subjective viewpoint, as the Swift error handling system is widely used for bubbling up errors through the system. Returning |
No no, real errors for error cases are just fine :-) I've got a "Swift Error Breakpoint" set in Xcode (added via the little // Handle error thrown by CDA.
if let error = try? ContentfulError(map: map) {
completion(Result.error(error))
return
} The case that the JSON does not represent an error (i.e. can't be mapped to a However, on further investigation I found out, that the It'd probably be best to use a different approach to check if it's an error or not than to try to create one. Currently it's also impossible to distinguish between "it's not an error" and "it's an error, but the parsing failed". |
During development I use a "Swift Error" breakpoint. Contentful throws unnecessary exceptions while working totally fine. This is confusing and bad style. For example
ContentfulError
throws instead of returningnil
. Optional initializers should be used instead.The text was updated successfully, but these errors were encountered: