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

makeRequest() should throw instead of returning optional #7

Open
jbradforddillon opened this issue May 4, 2018 · 3 comments
Open

Comments

@jbradforddillon
Copy link

Service.makeRequest() currently returns ServiceRequest?, which allows it to fail gracefully if anything is misconfigured. For example, if the Container doesn't include an endpoint provider, or if the endpoint requested doesn't exist.

In any failure case, the call site should be required to catch a more descriptive error and make the right decision. In most cases this will be a no op (same as it is today).

The big win here would be in unit testing and getting this plumbing working the first time.

@ktatroe
Copy link

ktatroe commented May 4, 2018

I agree. Early Swift design patterns shied away from throws, but it's definitely become more accepted. I'd want to do a pass through the whole API to do an errors sweep. (Just got off doing that on another project, and have a lot better understanding of what makes a good error pattern now.)

@kpcwatson
Copy link

Additionally, the resolve methods in Container should throw rather than return nil.

@jbradforddillon
Copy link
Author

I agree with this as well. I have a branch with makeRequest throwing. @kpcwatson Could you put up a branch with the Container change so we can look at it? That would have some far-reaching effects, but would be fairly simple to ingest.

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

No branches or pull requests

3 participants