Class SshException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.sshtools.common.ssh.SshException
All Implemented Interfaces:
Serializable

public class SshException extends Exception

Generic exception for J2SSH Maverick exception handling. When an exception is thrown a reason is attached to the exception so that the developer can determine if its possible to proceed with the connection.

This

Author:
Lee David Painter
See Also:
  • Field Details

    • UNEXPECTED_TERMINATION

      public static final int UNEXPECTED_TERMINATION
      The connection unexpectedly terminated and so the connection can no longer be used. The exception message will contain the message from the exception that caused the termination.
      See Also:
    • REMOTE_HOST_DISCONNECTED

      public static final int REMOTE_HOST_DISCONNECTED
      The remote host disconnected following the normal SSH protocol disconnection procedure. The exception message will contain the message received from the remote host that describes the reason for the disconnection
      See Also:
    • PROTOCOL_VIOLATION

      public static final int PROTOCOL_VIOLATION
      The SSH protocol was violated in some way by the remote host and the connection has been terminated. The exception message will contain a description of the protocol violation.
      See Also:
    • BAD_API_USAGE

      public static final int BAD_API_USAGE
      The API has encountered an error because of incorrect usage. The state of the connection upon receiving this exception is unknown.
      See Also:
    • INTERNAL_ERROR

      public static final int INTERNAL_ERROR
      An internal error occurred within the API; in all cases contact sshtools.com support with the details of this error and the state of the connection when receiving this exception is unknown.
      See Also:
    • CHANNEL_FAILURE

      public static final int CHANNEL_FAILURE
      Indicates that a channel has failed; this is used by channel implementations (such as port forwarding or session channels) to indicate that the channel has critically failed. Upon receiving this exception you should check the connection state to determine whether its still possible to use the connection.
      See Also:
    • UNSUPPORTED_ALGORITHM

      public static final int UNSUPPORTED_ALGORITHM
      In setting up a context an algorithm was specified that is not supported by the API.
      See Also:
    • CANCELLED_CONNECTION

      public static final int CANCELLED_CONNECTION
      The user cancelled the connection.
      See Also:
    • KEY_EXCHANGE_FAILED

      public static final int KEY_EXCHANGE_FAILED
      The protocol failed to negotiate a transport algorithm or failed to verify the host key of the remote host.
      See Also:
    • CONNECT_FAILED

      public static final int CONNECT_FAILED
      The connection could not be established.
      See Also:
    • LICENSE_ERROR

      public static final int LICENSE_ERROR
      The API is not licensed!
      See Also:
    • CONNECTION_CLOSED

      public static final int CONNECTION_CLOSED
      An attempt has been made to use a connection that has been closed and is no longer valid.
      See Also:
    • AGENT_ERROR

      public static final int AGENT_ERROR
      An error has occurred within the agent.
      See Also:
    • FORWARDING_ERROR

      public static final int FORWARDING_ERROR
      An error has occurred the port forwarding system.
      See Also:
    • PSEUDO_TTY_ERROR

      public static final int PSEUDO_TTY_ERROR
      A request was made to allocate a pseudo terminal, but this request failed.
      See Also:
    • SHELL_ERROR

      public static final int SHELL_ERROR
      A request was made to start a shell, but this request failed.
      See Also:
    • SESSION_STREAM_ERROR

      public static final int SESSION_STREAM_ERROR
      An error occurred whilst accessing a sessions streams
      See Also:
    • JCE_ERROR

      public static final int JCE_ERROR
      An error occurred in the JCE; typically this would result from Maverick attempting to use an algorithm that the JCE does not support.
      See Also:
    • POSSIBLE_CORRUPT_FILE

      public static final int POSSIBLE_CORRUPT_FILE
      An error occurred reading the contents of a file. Its possible that the file is not correctly formatted.
      See Also:
    • SCP_TRANSFER_CANCELLED

      public static final int SCP_TRANSFER_CANCELLED
      The user cancelled an active SCP transfer.
      See Also:
    • SOCKET_TIMEOUT

      public static final int SOCKET_TIMEOUT
      The API detected a socket timeout
      See Also:
    • PROMPT_TIMEOUT

      public static final int PROMPT_TIMEOUT
      The Shell class failed to detect the prompt.
      See Also:
    • MESSAGE_TIMEOUT

      public static final int MESSAGE_TIMEOUT
      An expected message was not received before the specified timeout period.
      See Also:
    • HOST_KEY_ERROR

      public static final int HOST_KEY_ERROR
      API error to indicate a host key signature failed.
      See Also:
    • UNSUPPORTED_OPERATION

      public static final int UNSUPPORTED_OPERATION
      An operation was not supported
      See Also:
  • Constructor Details

    • SshException

      public SshException(String msg, int reason)
      Create an exception with the given description and reason.
      Parameters:
      msg -
      reason -
    • SshException

      public SshException(int reason, String msg)
      Create an exception with the given description and reason (for compatibility with Legacy API).
      Parameters:
      msg -
      reason -
    • SshException

      public SshException(int reason, Throwable cause)
      Create an exception with the given cause and reason.
      Parameters:
      reason -
      cause -
    • SshException

      public SshException(Throwable cause, int reason)
    • SshException

      public SshException(String msg, Throwable cause)
      Create an exception with the given description and cause. The reason given will be INTERNAL_ERROR.
      Parameters:
      msg -
      cause -
    • SshException

      public SshException(Throwable cause)
      Create an exception by providing the cause of the error. This constructor sets the reason to INTERNAL_ERROR.
      Parameters:
      cause -
    • SshException

      public SshException(String msg, int reason, Throwable cause)
      Create an exception with the given description cause, reason.
      Parameters:
      msg -
      reason -
      cause -
  • Method Details

    • getReason

      public int getReason()
      Get the reason for the exception
      Returns:
      int
    • getCause

      public Throwable getCause()
      If an INTERNAL_ERROR reason is given this method MAY return the cause of the error.
      Overrides:
      getCause in class Throwable
      Returns:
      Throwable