Permalink
Browse files

Extract error messages from the envelope metadata section

  • Loading branch information...
1 parent 6a857e0 commit bb0957693322b9af60a9e9f0e2736cae58ce3670 Brent Royal-Gordon committed Oct 28, 2012
Showing with 12 additions and 2 deletions.
  1. +10 −2 ANRequest.m
  2. +1 −0 ANResponse.h
  3. +1 −0 ANResponse.m
View
@@ -206,9 +206,17 @@ - (void)sendRequestWithRepresentationCompletion:(void (^)(ANResponse *, id, NSEr
if(!error) {
error = jsonError;
}
- if(error && json) {
+ if(error && (response || json)) {
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
- [userInfo setObject:json forKey:@"json"];
+
+ [userInfo setObject:error forKey:NSUnderlyingErrorKey];
+ if(json) {
+ [userInfo setObject:json forKey:@"json"];
+ }
+ if(response.errorMessage) {
+ [userInfo setObject:response.errorMessage forKey:NSLocalizedDescriptionKey];
+ }
+
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
json = nil;
View
@@ -13,6 +13,7 @@
@interface ANResponse : ANResource
@property (nonatomic,readonly) NSUInteger statusCode;
+@property (nonatomic,readonly) NSString * errorMessage;
@property (nonatomic,readonly) ANResourceID earliestID;
@property (nonatomic,readonly) ANResourceID latestID;
View
@@ -23,6 +23,7 @@ @implementation ANResponse
@dynamic minID;
@dynamic maxID;
@dynamic more;
+@dynamic errorMessage;
- (NSUInteger)statusCode {
return self.code;

0 comments on commit bb09576

Please sign in to comment.