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

Change API call signatures to use ErrorType instead of NSError #81

Open
cojoj opened this issue Jul 24, 2015 · 4 comments
Open

Change API call signatures to use ErrorType instead of NSError #81

cojoj opened this issue Jul 24, 2015 · 4 comments

Comments

@cojoj
Copy link
Contributor

cojoj commented Jul 24, 2015

Right now most of our API endpoint methods (these located in XcodeServer extensions) are constructed in non-swifty way - they return optional NSError pointers.

How about gradually changing them to throwing methods?
There are some benefits of doing this:

  1. Swifty way (most important argument... 😜)
  2. Reduce amount of Optionals
  3. More descriptive errors, as they'll be enums

I know, I know, I may be overreacting... Maybe that's because I have too much free time? 😝

@czechboy0
Copy link
Member

Can you provide an example? AFAIK, all our APIs are asynchronous, so the callback block is called much later after the call of the API method. Throw only works with synchronous calls.

What we could do is change the signature from NSError to ErrorType. That would be a good improvement, because it would allow for error enum types.

@cojoj
Copy link
Contributor Author

cojoj commented Jul 24, 2015

Right, async... And I'm back home 😉 But we have more methods which may be considered this way eg. createRequest() returns NSMutableRequest?.

Anyway, ErrorTypes sounds great!

@czechboy0
Copy link
Member

Yup, createRequest() would be a good candidate for throwing.

@czechboy0
Copy link
Member

Action: look into changing the error type in API call block callbacks from NSError to ErrorType.

@czechboy0 czechboy0 changed the title API calls method signatures API calls - NSError -> ErrorType Jul 27, 2015
@czechboy0 czechboy0 changed the title API calls - NSError -> ErrorType Change API call signatures to use ErrorType instead of NSError Sep 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants