本文整理汇总了Java中com.google.apphosting.api.ApiProxy.UnknownException方法的典型用法代码示例。如果您正苦于以下问题:Java ApiProxy.UnknownException方法的具体用法?Java ApiProxy.UnknownException怎么用?Java ApiProxy.UnknownException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.apphosting.api.ApiProxy
的用法示例。
在下文中一共展示了ApiProxy.UnknownException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUnknownRpcError
import com.google.apphosting.api.ApiProxy; //导入方法依赖的package包/类
public void testUnknownRpcError() throws Exception {
RemoteApiPb.RpcError rpcError = new RemoteApiPb.RpcError();
rpcError.setCode(123456);
ApiProxyException expectedException =
new ApiProxy.UnknownException(TEST_PACKAGE_NAME, TEST_METHOD_NAME);
callDelegateWithOneError(false, rpcError, null, expectedException);
}
示例2: convertApiResponseRpcErrorToException
import com.google.apphosting.api.ApiProxy; //导入方法依赖的package包/类
/**
* Convert the RemoteApiPb.RpcError to the appropriate exception.
*
* @param rpcError the RemoteApiPb.RpcError.
* @param packageName the name of the API package.
* @param methodName the name of the method within the API package.
* @param logger the Logger used to create log messages.
* @return ApiProxyException
*/
private static ApiProxyException convertApiResponseRpcErrorToException(
RemoteApiPb.RpcError rpcError, String packageName, String methodName, Logger logger) {
int rpcCode = rpcError.getCode();
String errorDetail = rpcError.getDetail();
if (rpcCode > RemoteApiPb.RpcError.ErrorCode.values().length) {
logger.severe("Received unrecognized error code from server: " + rpcError.getCode() +
" details: " + errorDetail);
return new ApiProxy.UnknownException(packageName, methodName);
}
RemoteApiPb.RpcError.ErrorCode errorCode = RemoteApiPb.RpcError.ErrorCode.values()[
rpcError.getCode()];
logger.warning("RPC failed, API=" + packageName + "." + methodName + " : "
+ errorCode + " : " + errorDetail);
// This is very similar to apphosting/utils/runtime/ApiProxyUtils.java#convertApiError,
// which is for APIResponse. TODO(user): retire both in favor of gRPC.
switch (errorCode) {
case CALL_NOT_FOUND:
return new ApiProxy.CallNotFoundException(packageName, methodName);
case PARSE_ERROR:
return new ApiProxy.ArgumentException(packageName, methodName);
case SECURITY_VIOLATION:
logger.severe("Security violation: invalid request id used!");
return new ApiProxy.UnknownException(packageName, methodName);
case CAPABILITY_DISABLED:
return new ApiProxy.CapabilityDisabledException(
errorDetail, packageName, methodName);
case OVER_QUOTA:
return new ApiProxy.OverQuotaException(packageName, methodName);
case REQUEST_TOO_LARGE:
return new ApiProxy.RequestTooLargeException(packageName, methodName);
case RESPONSE_TOO_LARGE:
return new ApiProxy.ResponseTooLargeException(packageName, methodName);
case BAD_REQUEST:
return new ApiProxy.ArgumentException(packageName, methodName);
case CANCELLED:
return new ApiProxy.CancelledException(packageName, methodName);
case FEATURE_DISABLED:
return new ApiProxy.FeatureNotEnabledException(
errorDetail, packageName, methodName);
case DEADLINE_EXCEEDED:
return new ApiProxy.ApiDeadlineExceededException(packageName, methodName);
default:
return new ApiProxy.UnknownException(packageName, methodName);
}
}