Move ErrorForBadProto

pull/20107/head
Muxi Yan 5 years ago
parent 56acfb9f26
commit e7c9b46a1e
  1. 18
      src/objective-c/ProtoRPC/ProtoRPC.m
  2. 18
      src/objective-c/ProtoRPC/ProtoRPCLegacy.m

@ -273,3 +273,21 @@
}
@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];
}

@ -101,21 +101,3 @@
@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