ServiceStateException (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.service, class: ServiceStateException

Package org.apache.hadoop.service

# Class ServiceStateException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.apache.hadoop.service.ServiceStateException

All Implemented Interfaces:
  `Serializable`, `org.apache.hadoop.util.ExitCodeProvider`

@Public @Evolving public class ServiceStateException extends RuntimeException implements org.apache.hadoop.util.ExitCodeProvider
Exception that can be raised on state change operations, whose exit code can be explicitly set, determined from that of any nested cause, or a default value of `LauncherExitCodes.EXIT_SERVICE_LIFECYCLE_EXCEPTION`.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ServiceStateException(int exitCode, String message, Throwable cause)`
  Instantiate, using the specified exit code as the exit code of the exception, irrespetive of any exit code supplied by any inner cause.
  `ServiceStateException(String message)`
  Instantiate
  `ServiceStateException(String message, Throwable cause)`
  Instantiate with a message and cause; if the cause has an exit code then it is used, otherwise the generic `LauncherExitCodes.EXIT_SERVICE_LIFECYCLE_EXCEPTION` exit code is used.
  `ServiceStateException(Throwable cause)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static RuntimeException`
  `convert(String text, Throwable fault)`
  Convert any exception into a `RuntimeException`.
  `static RuntimeException`
  `convert(Throwable fault)`
  Convert any exception into a `RuntimeException`.
  `int`
  `getExitCode()`
  Method to get the exit code.

  ### Methods inherited from class java.lang.Throwable

  `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### ServiceStateException

    public ServiceStateException(String message)
    Instantiate
    Parameters:
      `message` - error message

  - ### ServiceStateException

    public ServiceStateException(String message, Throwable cause)
    Instantiate with a message and cause; if the cause has an exit code then it is used, otherwise the generic `LauncherExitCodes.EXIT_SERVICE_LIFECYCLE_EXCEPTION` exit code is used.
    Parameters:
      `message` - exception message
      `cause` - optional inner cause

  - ### ServiceStateException

    public ServiceStateException(int exitCode, String message, Throwable cause)
    Instantiate, using the specified exit code as the exit code of the exception, irrespetive of any exit code supplied by any inner cause.
    Parameters:
      `exitCode` - exit code to declare
      `message` - exception message
      `cause` - inner cause

  - ### ServiceStateException

    public ServiceStateException(Throwable cause)

- ## Method Details

  - ### getExitCode

    public int getExitCode()
    Description copied from interface: `org.apache.hadoop.util.ExitCodeProvider`
    Method to get the exit code.
    Specified by:
      `getExitCode` in interface `org.apache.hadoop.util.ExitCodeProvider`
    Returns:
      the exit code

  - ### convert

    public static RuntimeException convert(Throwable fault)
    Convert any exception into a `RuntimeException`. All other exception types are wrapped in a new instance of `ServiceStateException`.
    Parameters:
      `fault` - exception or throwable
    Returns:
      a `RuntimeException` to rethrow

  - ### convert

    public static RuntimeException convert(String text, Throwable fault)
    Convert any exception into a `RuntimeException`. If the caught exception is already of that type, it is typecast to a `RuntimeException` and returned. All other exception types are wrapped in a new instance of `ServiceStateException`.
    Parameters:
      `text` - text to use if a new exception is created
      `fault` - exception or throwable
    Returns:
      a `RuntimeException` to rethrow