Class NutException

java.lang.Object
java.lang.Throwable
java.lang.Exception
org.networkupstools.jnut.NutException
All Implemented Interfaces:
Serializable

public class NutException extends Exception
Class representing a NUT exception.

Instances of this class are thrown when an UPSD returns an error with an "ERR" directive. Moreover, it can be thrown with some extra errors like:

  • UNKNOWN-RESPONSE: The response is not understood
  • SERVER-NOT-CONNECTED: The Client is not connected to the data server yet

A NutException has a standard Java exception message which corresponds to error code returned by UPSD (like 'ACCESS-DENIED', 'UNKNOWN-UPS' ...) or defined in the class (like 'UNKNOWN-RESPONSE', 'SERVER-NOT-CONNECTED'). An extra string can be used to embed a more descriptive English message.

The is(String) method can be used to test if the exception corresponds to a specific well-known error code.

Author:
Emilien Kia
See Also:
  • Field Details

    • UnknownResponse

      public static String UnknownResponse
    • DriverNotConnected

      public static String DriverNotConnected
    • ServerNotConnected

      public static String ServerNotConnected
      Not a NUT message, but internal report when Client.isConnected() returns false during a query (preparing to `get`, etc.)
    • extra

      public String extra
  • Constructor Details

    • NutException

      public NutException()
    • NutException

      public NutException(String message)
    • NutException

      public NutException(String message, String extra)
    • NutException

      public NutException(Throwable cause)
    • NutException

      public NutException(String message, Throwable cause)
    • NutException

      public NutException(String message, String extra, Throwable cause)
  • Method Details

    • getExtra

      public String getExtra()
      Returns the extra message.
      Returns:
      Extra message if any.
    • setExtra

      public void setExtra(String extra)
      Set the extra message.
      Parameters:
      extra - The new extra message.
    • is

      public boolean is(String name)
      Test is the exception corresponds to the specified well-known problem name.
      Parameters:
      name - Name to test
      Returns:
      True if the exception corresponds.
    • toString

      public String toString()
      Format an exception message.
      Overrides:
      toString in class Throwable
      Returns:
      Exception message