3

I'm using latest AFNetworking for my app which speaks with REST API server.

When I get some 500 error from it with JSON body something like

{ "message": "my error message" },

I cannot retrieve this message from NSError which lib responds to me:

[api setupUser:data success:^(AFHTTPRequestOperation *operation, id responseObject) {
   // some success handle
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
   // cannot get json response of error :(
}];

How do you workaround it?

PREMKUMAR
  • 8,283
  • 8
  • 28
  • 51
Kosmetika
  • 20,774
  • 37
  • 108
  • 172

1 Answers1

13

The answer was simple - operation.responseObject in failure callback contains json data as well. Sweet ^.^

Kosmetika
  • 20,774
  • 37
  • 108
  • 172