Class ApiProxyUtils


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.google.apphosting.api.ApiProxy.ApiProxyException convertApiError​(com.google.apphosting.base.protos.RuntimePb.APIResponse apiResponse, String packageName, String methodName, com.google.common.flogger.GoogleLogger logger)
      Convert APIResponse.getError() to the appropriate exception.
      static com.google.apphosting.api.ApiProxy.ApiProxyException getApiError​(String packageName, String methodName, com.google.apphosting.base.protos.api.RemoteApiPb.Response response, com.google.common.flogger.GoogleLogger logger)
      Provides a throwable exception for HTTP API transport-level RPC errors.
      static com.google.apphosting.api.ApiProxy.ApiProxyException getApiError​(String packageName, String methodName, com.google.apphosting.base.protos.RuntimePb.APIResponse apiResponse, com.google.common.flogger.GoogleLogger logger)
      Provides a throwable exception for HTTP API transport-level RPC errors.
      static com.google.apphosting.api.ApiProxy.ApiProxyException getRpcError​(String packageName, String methodName, com.google.apphosting.base.protos.Status.StatusProto status, int applicationError, String errorDetail, Throwable cause)
      Provides a throwable exception for HTTP API RPC user-application errors.
      static com.google.apphosting.base.protos.RuntimePb.APIResponse.ERROR remoteApiErrorToApiResponseError​(com.google.apphosting.base.protos.api.RemoteApiPb.Response responsePb)
      Converts a RemoteApiPb RPC error code into an APIResponse error code.
      static Optional<com.google.apphosting.api.ApiProxy.ApiProxyException> statusException​(com.google.apphosting.base.protos.Status.StatusProto status, String packageName, String methodName, Throwable cause)
      Provides errors based on the status of the HTTP response.
    • Method Detail

      • convertApiError

        public static com.google.apphosting.api.ApiProxy.ApiProxyException convertApiError​(com.google.apphosting.base.protos.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 com.google.apphosting.api.ApiProxy.ApiProxyException getRpcError​(String packageName,
                                                                                       String methodName,
                                                                                       com.google.apphosting.base.protos.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 com.google.apphosting.api.ApiProxy.ApiProxyException getApiError​(String packageName,
                                                                                       String methodName,
                                                                                       com.google.apphosting.base.protos.api.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 com.google.apphosting.api.ApiProxy.ApiProxyException getApiError​(String packageName,
                                                                                       String methodName,
                                                                                       com.google.apphosting.base.protos.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<com.google.apphosting.api.ApiProxy.ApiProxyException> statusException​(com.google.apphosting.base.protos.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 com.google.apphosting.base.protos.RuntimePb.APIResponse.ERROR remoteApiErrorToApiResponseError​(com.google.apphosting.base.protos.api.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.