Class ErrorsHelper

java.lang.Object
com.oracle.coherence.grpc.ErrorsHelper

public final class ErrorsHelper extends Object
Error helper methods.
Since:
20.06
Author:
Jonathan Knight 2019.11.28
  • Field Details

    • KEY_ERROR

      public static final io.grpc.Metadata.Key<String> KEY_ERROR
      The metadata key for an exception stack trace.
    • SAFE_INTERNAL_ERROR_MESSAGE

      public static final String SAFE_INTERNAL_ERROR_MESSAGE
      Bounded generic message for unhandled internal errors in safe mode.
      See Also:
  • Method Details

    • ensureStatusRuntimeException

      public static io.grpc.StatusRuntimeException ensureStatusRuntimeException(Throwable t)
      Convert a Throwable to a StatusRuntimeException.
      Parameters:
      t - the Throwable to convert
      Returns:
      a StatusRuntimeException
    • ensureStatusRuntimeExceptionWithPolicy

      public static io.grpc.StatusRuntimeException ensureStatusRuntimeExceptionWithPolicy(Throwable t, String sErrorDisclosure)
      Convert a Throwable to a StatusRuntimeException.
      Parameters:
      t - the Throwable to convert
      sErrorDisclosure - the gRPC error-disclosure policy
      Returns:
      a StatusRuntimeException
    • ensureStatusRuntimeException

      public static io.grpc.StatusRuntimeException ensureStatusRuntimeException(Throwable t, String description)
      Convert a Throwable to a StatusRuntimeException.
      Parameters:
      t - the Throwable to convert
      description - the description to add to the exception
      Returns:
      a StatusRuntimeException
    • ensureStatusRuntimeException

      public static io.grpc.StatusRuntimeException ensureStatusRuntimeException(Throwable t, String description, String sErrorDisclosure)
      Convert a Throwable to a StatusRuntimeException.
      Parameters:
      t - the Throwable to convert
      description - the description to add to the exception
      sErrorDisclosure - the gRPC error-disclosure policy
      Returns:
      a StatusRuntimeException
    • getRemoteStack

      public static Optional<String> getRemoteStack(io.grpc.StatusRuntimeException e)
      Obtain the remote stack trace from the specified StatusRuntimeException.
      Parameters:
      e - the exception returned from a server call
      Returns:
      the remote stack trace, or an empty Optional if no remote stack is present.
    • getRemoteStack

      public static Optional<String> getRemoteStack(io.grpc.StatusException e)
      Obtain the remote stack trace from the specified StatusException.
      Parameters:
      e - the exception returned from a server call
      Returns:
      the remote stack trace, or an empty Optional if no remote stack is present.
    • createException

      public static RequestIncompleteException createException(com.oracle.coherence.grpc.messages.common.v1.ErrorMessage error, Serializer serializer)
      Create a RequestIncompleteException from an ErrorMessage.
      Parameters:
      error - the ErrorMessage
      serializer - the Serializer to deserialize the stack trace
      Returns:
      the RequestIncompleteException created from the ErrorMessage
    • createException

      public static <E extends Exception> E createException(com.oracle.coherence.grpc.messages.common.v1.ErrorMessage error, Serializer serializer, BiFunction<String, Throwable, E> factory)
      Create an exception from an ErrorMessage.
      Type Parameters:
      E - the type of exception to return
      Parameters:
      error - the ErrorMessage
      serializer - the Serializer to deserialize the stack trace
      factory - the factory function to create the resulting exception
      Returns:
      the exception created from the ErrorMessage
    • createErrorMessage

      public static com.oracle.coherence.grpc.messages.common.v1.ErrorMessage createErrorMessage(Throwable error, Serializer serializer)
      Create an ErrorMessage from a Throwable.
      Parameters:
      error - the error to create the message from
      serializer - the serializer to use to serialize the stack trace
      Returns:
      the error message
    • createErrorMessage

      public static com.oracle.coherence.grpc.messages.common.v1.ErrorMessage createErrorMessage(Throwable error, Serializer serializer, String sErrorDisclosure)
      Create an ErrorMessage from a Throwable.
      Parameters:
      error - the error to create the message from
      serializer - the serializer to use to serialize the stack trace
      sErrorDisclosure - the gRPC error-disclosure policy
      Returns:
      the error message
    • logIfNotCancelled

      public static void logIfNotCancelled(Throwable t)
      Log the exception unless it is a StatusRuntimeException with a status of Status.CANCELLED.
      Parameters:
      t - the exception to log