Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Exception handling #2

Open
t0lkman opened this issue May 7, 2012 · 5 comments
Open

Exception handling #2

t0lkman opened this issue May 7, 2012 · 5 comments

Comments

@t0lkman
Copy link

t0lkman commented May 7, 2012

Can you post some examples how to handle exceptions?

let say you do
[RFService execRequest:r completion:^(RFResponse *response) {

but server is not available or the document is not found (404)

@ivasic
Copy link
Owner

ivasic commented May 8, 2012

You'll just need to check RFResponse's error property:

/*!

  • @Property error
  • @abstract This propery will hold NSError if one occurs during request. NULL if there's no error
    /
    @Property (nonatomic, readonly, retain) NSError
    error;

This property will contain the NSError in case something goes wrong.
For HTTP errors you can also check the httpCode property of RFResponse:

/*!

basically you'd do something like

[RFService execRequest:r completion:^(RFResponse *response) {
if (response.error) {
//there's an error, handle it
return;
}
if (response.httpCode == 200) {
//all good
} else {
//check your status
}
}]

@ivasic
Copy link
Owner

ivasic commented May 8, 2012

I'll update the README file with some examples and close this issue when I do...

@t0lkman
Copy link
Author

t0lkman commented May 8, 2012

Great, Thank you.
The wrapper looks promising :)

@t0lkman
Copy link
Author

t0lkman commented May 9, 2012

Just want to confirm, it's working!
How about additional headers? I want pass my custom user-agent http header
is there anyway?

@ivasic
Copy link
Owner

ivasic commented May 9, 2012

Yeah, just use additionalHTTPHeaders property of RFRequest.

/*!

  • @Property additionalHTTPHeaders
  • @abstract Additional HTTP headers in form of key/value dictionary to include with the HTTP request
    /
    @Property (nonatomic, retain) NSDictionary
    additionalHTTPHeaders;

Just add key-value pairs to a NSDictionary and assign to this property.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants