Class UserException.Builder

java.lang.Object
org.apache.drill.common.exceptions.UserException.Builder
Enclosing class:
UserException

public static class UserException.Builder extends Object
Builder class for DrillUserException. You can wrap an existing exception, in this case it will first check if this exception is, or wraps, a DrillUserException. If it does then the builder will use the user exception as it is (it will ignore the message passed to the constructor) and will add any additional context information to the exception's context
  • Method Details

    • errorType

      Sets the error type. This method is normally not needed because of the per-error-type static initialiser methods above but it may be used in conjunction with UserException.rebuild() to clone an existing UserException modified to use a different error type.
      Parameters:
      errorType - the error type to set.
      Returns:
      this builder.
    • message

      public UserException.Builder message(String format, Object... args)
      sets or replaces the error message.

      This will be ignored if this builder is wrapping a user exception

      Parameters:
      format - format string
      args - Arguments referenced by the format specifiers in the format string
      Returns:
      this builder
      See Also:
    • addIdentity

      add DrillbitEndpoint identity to the context.

      if the context already has a drillbitEndpoint identity, the new identity will be ignored

      Parameters:
      endpoint - drillbit endpoint identity
    • addContext

      public UserException.Builder addContext(String value)
      add a string line to the bottom of the context
      Parameters:
      value - string line
      Returns:
      this builder
    • addContext

      public UserException.Builder addContext(String value, Object... args)
      add a string line to the bottom of the context
      Parameters:
      value - string line
      Returns:
      this builder
    • addContext

      public UserException.Builder addContext(String name, String value)
      add a string value to the bottom of the context
      Parameters:
      name - context name
      value - context value
      Returns:
      this builder
    • addContext

      public UserException.Builder addContext(String name, long value)
      add a long value to the bottom of the context
      Parameters:
      name - context name
      value - context value
      Returns:
      this builder
    • addContext

      public UserException.Builder addContext(String name, double value)
      add a double value to the bottom of the context
      Parameters:
      name - context name
      value - context value
      Returns:
      this builder
    • addContext

      public UserException.Builder addContext(CustomErrorContext context)
    • pushContext

      public UserException.Builder pushContext(String value)
      pushes a string value to the top of the context
      Parameters:
      value - context value
      Returns:
      this builder
    • pushContext

      public UserException.Builder pushContext(String name, String value)
      pushes a string value to the top of the context
      Parameters:
      name - context name
      value - context value
      Returns:
      this builder
    • pushContext

      public UserException.Builder pushContext(String name, long value)
      pushes a long value to the top of the context
      Parameters:
      name - context name
      value - context value
      Returns:
      this builder
    • pushContext

      public UserException.Builder pushContext(String name, double value)
      pushes a double value to the top of the context
      Parameters:
      name - context name
      value - context value
      Returns:
      this builder
    • build

      public UserException build(org.slf4j.Logger logger)
      builds a user exception or returns the wrapped one. If the error is a system error, the error message is logged to the given Logger.
      Parameters:
      logger - the logger to write to
      Returns:
      user exception
    • build

      @Deprecated public UserException build()
      Deprecated.
      Use build(Logger) instead. If the error is a system error, the error message is logged to this UserException.logger.
      Builds a user exception or returns the wrapped one.
      Returns:
      user exception