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

Documentation questions/errors? #812

Open
scottrhoyt opened this issue Nov 30, 2016 · 3 comments
Open

Documentation questions/errors? #812

scottrhoyt opened this issue Nov 30, 2016 · 3 comments

Comments

@scottrhoyt
Copy link
Contributor

In README.md

Carthage users can point to this repository and use whichever generated framework they'd like, Moya, RxMoya, or ReactiveMoya. The full Moya framework is bundled in each of those frameworks; importing more than one framework in a single file will result in ambiguous lookups at compile time.

This appears to be true for basic usage. However, I get undefined symbol errors for Response if I don't also include Moya with RxMoya. I run into this whenever I want to create custom Rx operators for Observable<Response>. I have not run into any ambiguous lookups yet.


In docs/RxSwift.md

In the error cases, the error's domain is MoyaErrorDomain. The code is one of MoyaErrorCode's rawValues, where appropriate. Wherever possible, underlying errors are provided and the original response data is included in the NSError's userInfo dictionary using the "data" key.

The domain of the NSError that I see is Moya.Error. Also, it doesn't appear that the userInfo dictionary contains any items, and I can't see where in the code this would be the case. Maybe there is some magic happening under the hood when bridging Error to NSError?

In any case, when I need to process the response in error cases, I don't bridge to NSError and instead:

if 
   let error = error as? Moya.Error,
   let data = error.response?.data
{
   // Do something with the data
}
@BasThomas
Copy link
Contributor

On the error: am I right you are expecting the error's response data to be in the NSError's userInfo? I think that would make sense to do.

@scottrhoyt
Copy link
Contributor Author

Well, at least my reading of the docs lead me to believe that I could extract the original response data by casting the Moya.Error to an NSError and then retrieving its userInfo["data"] value. That didn't work for me. Retrieving the response is straightforward the way I mentioned above, it's just different than what the docs say.

@AndrewSB
Copy link
Member

AndrewSB commented Dec 2, 2016

@scottrhoyt thank you for checking out the README. The issue you ran into with RxMoya not having Response defined stems from changes made in #563.

Previously both RxMoya and ReactiveMoya were fat (they also contained all of the Moya source code), but this change made them slim (they dont contain Moya, so are dependent on Moya being imported as well).

Not updating the README was an oversight, it should have been updated in tandem with #563. We should create a pull request to update that documentation.

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

4 participants