From 1d038a8f2970168901071c17f4dcc1765690a00a Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 24 Jul 2019 20:57:54 -0700 Subject: [PATCH] More proto fixes --- src/objective-c/GRPCClient/GRPCCall.h | 2 -- src/objective-c/ProtoRPC/ProtoRPC.h | 9 +++------ src/objective-c/ProtoRPC/ProtoRPC.m | 18 ------------------ src/objective-c/ProtoRPC/ProtoRPCLegacy.h | 7 ++++++- src/objective-c/ProtoRPC/ProtoRPCLegacy.m | 19 +++++++++++++++++++ 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 2ab69480fb8..153ddc5c171 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -54,8 +54,6 @@ extern NSString *const kGRPCErrorDomain; * server applications to produce. */ typedef NS_ENUM(NSUInteger, GRPCErrorCode) { - GRPCErrorCodeOk = 0, - /** The operation was cancelled (typically by the caller). */ GRPCErrorCodeCancelled = 1, diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h index ab9a180eb97..c91adc7b7cd 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.h +++ b/src/objective-c/ProtoRPC/ProtoRPC.h @@ -18,6 +18,9 @@ #import +// import legacy header for compatibility with users using the ProtoRPC interface +#import "ProtoRPCLegacy.h" + #import "ProtoMethod.h" NS_ASSUME_NONNULL_BEGIN @@ -160,10 +163,4 @@ NS_ASSUME_NONNULL_BEGIN @end -/** - * Generate an NSError object that represents a failure in parsing a proto class. For gRPC internal - * use only. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); - NS_ASSUME_NONNULL_END diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m index 4067dbd1820..dbfa3c0f23d 100644 --- a/src/objective-c/ProtoRPC/ProtoRPC.m +++ b/src/objective-c/ProtoRPC/ProtoRPC.m @@ -27,24 +27,6 @@ #import #import -/** - * Generate an NSError object that represents a failure in parsing a proto class. - */ -NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { - NSDictionary *info = @{ - NSLocalizedDescriptionKey : @"Unable to parse response from the server", - NSLocalizedRecoverySuggestionErrorKey : - @"If this RPC is idempotent, retry " - @"with exponential backoff. Otherwise, query the server status before " - @"retrying.", - 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 GRPCUnaryProtoCall { GRPCStreamingProtoCall *_call; GPBMessage *_message; diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h index 893d8047104..bff487e9a0b 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.h +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.h @@ -1,4 +1,3 @@ -#import "ProtoRPC.h" #import @class GRPCProtoMethod; @@ -32,3 +31,9 @@ __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC @end +/** + * Generate an NSError object that represents a failure in parsing a proto class. For gRPC internal + * use only. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError); + diff --git a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m index 45f873dc889..d20da5db840 100644 --- a/src/objective-c/ProtoRPC/ProtoRPCLegacy.m +++ b/src/objective-c/ProtoRPC/ProtoRPCLegacy.m @@ -82,3 +82,22 @@ @implementation GRPCProtoCall @end + +/** + * Generate an NSError object that represents a failure in parsing a proto class. + */ +NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) { + NSDictionary *info = @{ + NSLocalizedDescriptionKey : @"Unable to parse response from the server", + NSLocalizedRecoverySuggestionErrorKey : + @"If this RPC is idempotent, retry " + @"with exponential backoff. Otherwise, query the server status before " + @"retrying.", + 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]; +} +