More proto fixes

pull/19704/head
Muxi Yan 6 years ago
parent 32aad8a11c
commit 1d038a8f29
  1. 2
      src/objective-c/GRPCClient/GRPCCall.h
  2. 9
      src/objective-c/ProtoRPC/ProtoRPC.h
  3. 18
      src/objective-c/ProtoRPC/ProtoRPC.m
  4. 7
      src/objective-c/ProtoRPC/ProtoRPCLegacy.h
  5. 19
      src/objective-c/ProtoRPC/ProtoRPCLegacy.m

@ -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,

@ -18,6 +18,9 @@
#import <Foundation/Foundation.h>
// 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

@ -27,24 +27,6 @@
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter+Transformations.h>
/**
* 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;

@ -1,4 +1,3 @@
#import "ProtoRPC.h"
#import <GRPCClient/GRPCCallLegacy.h>
@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);

@ -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];
}

Loading…
Cancel
Save