aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/ProtoRPC/ProtoRPC.m
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2015-09-03 02:39:36 -0700
committerGravatar Jorge Canizales <jcanizales@google.com>2015-09-03 02:41:19 -0700
commitafb7a0ee237fe1221f8c2c857387f82ff63c45c5 (patch)
treecb2b357becab567eef2fc1cfced8f64a057cd6e0 /src/objective-c/ProtoRPC/ProtoRPC.m
parente7209c588fdfe1bb96dc94dd7f06ee957be4a6b0 (diff)
Wrap parsing error appropriately before propagating.
Diffstat (limited to 'src/objective-c/ProtoRPC/ProtoRPC.m')
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 61fc0e3531..735ce0bdb5 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -37,6 +37,20 @@
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter+Transformations.h>
+static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) {
+ NSDictionary *info = @{
+ NSLocalizedDescriptionKey: @"Unable to parse response from the server",
+ NSLocalizedRecoverySuggestionErrorKey: @"Retry with exponential backoff",
+ NSUnderlyingErrorKey: parsingError,
+ @"Expected class": expectedClass,
+ @"Received value": proto,
+ };
+ // TODO(jcanizales): Use kGRPCErrorDomain and GRPCErrorCodeInternal when they're public.
+ return [NSError errorWithDomain:@"io.grpc"
+ code:13
+ userInfo:info];
+}
+
@implementation ProtoRPC {
id<GRXWriteable> _responseWriteable;
}
@@ -82,7 +96,7 @@
if (parsed) {
[responsesWriteable writeValue:parsed];
} else {
- [weakSelf finishWithError:error];
+ [weakSelf finishWithError:ErrorForBadProto(value, responseClass, error)];
}
} completionHandler:^(NSError *errorOrNil) {
[responsesWriteable writesFinishedWithError:errorOrNil];