Class ApiProxyUtils

java.lang.Object
com.google.apphosting.utils.runtime.ApiProxyUtils

public final class ApiProxyUtils extends Object
ApiProxyUtils is a utility class with functions shared by ApiProxy delegates, e.g. ApiProxyImpl, VmApiProxyDelegate.
  • Method Details

    • convertApiError

      public static ApiProxy.ApiProxyException convertApiError(RuntimePb.APIResponse apiResponse, String packageName, String methodName, com.google.common.flogger.GoogleLogger logger)
      Convert APIResponse.getError() to the appropriate exception.
      Parameters:
      apiResponse - the APIResponse
      packageName - the name of the API package.
      methodName - the name of the method within the API package.
      logger - the Logger used to create log messages.
      Returns:
      ApiProxyException
    • getRpcError

      public static ApiProxy.ApiProxyException getRpcError(String packageName, String methodName, Status.StatusProto status, int applicationError, String errorDetail, Throwable cause)
      Provides a throwable exception for HTTP API RPC user-application errors.
      Parameters:
      packageName - the package of the API being called, eg datastore_v3.
      methodName - the name of the method in the API being called, eg RunQuery.
      status - a status proto representing the response status.
      applicationError - error code representing the error.
      errorDetail - detailed message for the error.
      cause - exception to use as the cause (may be null).
      Returns:
      Exception, CapabilityDisabledException, or an ApplicationException
    • getApiError

      public static ApiProxy.ApiProxyException getApiError(String packageName, String methodName, RemoteApiPb.Response response, com.google.common.flogger.GoogleLogger logger)
      Provides a throwable exception for HTTP API transport-level RPC errors.
      Parameters:
      packageName - the package of the API being called, eg datastore_v3.
      methodName - the name of the method in the API being called, eg RunQuery.
      response - the response from the API server call.
      logger - the logger to use for logging warning messages.
      Returns:
      ApiProxyException
    • getApiError

      public static ApiProxy.ApiProxyException getApiError(String packageName, String methodName, RuntimePb.APIResponse apiResponse, com.google.common.flogger.GoogleLogger logger)
      Provides a throwable exception for HTTP API transport-level RPC errors.
      Parameters:
      packageName - the package of the API being called, eg datastore_v3.
      methodName - the name of the method in the API being called, eg RunQuery.
      apiResponse - the response from the API server call.
      logger - the logger to use for logging warning messages.
      Returns:
      ApiProxyException
    • statusException

      public static Optional<ApiProxy.ApiProxyException> statusException(Status.StatusProto status, String packageName, String methodName, Throwable cause)
      Provides errors based on the status of the HTTP response.
      Parameters:
      status - a status proto representing the response status.
      packageName - the package of the API being called, eg datastore_v3.
      methodName - the name of the method in the API being called, eg RunQuery.
      cause - the exception to chain as the cause (may be null).
      Returns:
      an optional Exception
    • remoteApiErrorToApiResponseError

      public static RuntimePb.APIResponse.ERROR remoteApiErrorToApiResponseError(RemoteApiPb.Response responsePb)
      Converts a RemoteApiPb RPC error code into an APIResponse error code.
      Parameters:
      responsePb - the response containing an error code to be converted.
      Returns:
      An APIResponse.ERROR that represents the original RemoteApiPb error code.