Class SevenZipException

All Implemented Interfaces:
Serializable

public class SevenZipException extends IOException
SevenZip core exception. This exception supports multiple 'caused by' exceptions. Use printStackTraceExtended() to get stack traces of all available causes. Multiple causes can occur, if native code is involved. If an exception is thrown in one of the callback Java methods, the native code will save this exception and may proceed with the next callback Java method, which can throw a further exception as well. After the native code completes, a new SevenZipException will be thrown. This exception will have multiple 'caused by' exceptions attached:
  • the exception thrown from the first callback Java method (first 'caused by' exception)
  • the exception thrown from the last callback Java method (last 'caused by' exception)
If more than two 'caused by' exceptions were thrown, only the first and last exceptions are saved.

In case of multi-threaded native code, a potential 'caused by' exception could be available in a SevenZipException. A potential 'caused by' exception situation can occur if, during a pending native call, a callback Java method is called from a new thread. Since an exception thrown in another thread can't always be reliably connected to the operation in progress (the main native call), the exception is saved as a potential first/last cause.

The methods provide full information about the underlying 'caused by' exceptions and nested SevenZipException. In order to improve readability of the long extended stack traces, the origin of the current exception being printed can be read vertically on the left of the stack trace. The standard Throwable.printStackTrace() method prints only the stack trace of the first 'caused by' exception.
Since:
4.65-1
Author:
Boris Brodski
See Also:
  • Constructor Details

    • SevenZipException

      public SevenZipException()
      Constructs a new exception with null as its detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(Throwable).
    • SevenZipException

      public SevenZipException(String message, Throwable cause)
      Constructs a new exception with the specified detail message and cause.

      Note that the detail message associated with cause is not automatically incorporated in this exception's detail message.

      Parameters:
      message - the detail message (which is saved for later retrieval by the getMessage() method).
      cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
      Since:
      4.65-1
    • SevenZipException

      public SevenZipException(String message)
      Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to Throwable.initCause(Throwable).
      Parameters:
      message - the detail message. The detail message is saved for later retrieval by the getMessage() method.
    • SevenZipException

      public SevenZipException(Throwable cause)
      Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for exceptions that are little more than wrappers for other throwables (for example, PrivilegedActionException).
      Parameters:
      cause - the cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
      Since:
      4.65-1
  • Method Details

    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable
    • getSevenZipExceptionMessage

      public String getSevenZipExceptionMessage()
      Get the original 7-Zip-JBinding exception error message (without the 'caused by' messages)
      Returns:
      original error message
    • printStackTraceExtended

      public void printStackTraceExtended()
      Prints stack traces of this SevenZipException and of all thrown 'caused by' exceptions to the specified system error stream System.err.
    • printStackTraceExtended

      public void printStackTraceExtended(PrintStream printStream)
      Prints stack trace of this SevenZipException and of all thrown 'caused by' exceptions to the specified print stream.
      Parameters:
      printStream - PrintStream to use for output
    • printStackTraceExtended

      public void printStackTraceExtended(PrintWriter printWriter)
      Prints stack trace of this SevenZipException and of all thrown 'caused by' exceptions to the specified print writer.
      Parameters:
      printWriter - PrintWriter to use for output
    • getCause

      public Throwable getCause()
      Get first thrown exception as a cause for this exception.
      Overrides:
      getCause in class Throwable
    • getCauseLastThrown

      public Throwable getCauseLastThrown()
      Get last thrown exception as a cause for this exception.
      Returns:
      null if no other (different to getCause()) exception known as a cause for this exception.
    • getCauseLastPotentialThrown

      public Throwable getCauseLastPotentialThrown()
      Get the last thrown exception that was the potential cause for this exception. The potential cause is an exception thrown in another thread where it's not possible to determine whether the exception has caused the current exception or not.
      Returns:
      null if no such exception was thrown.
    • getCauseFirstPotentialThrown

      public Throwable getCauseFirstPotentialThrown()
      Get the first thrown exception that was the potential cause for this exception. The potential cause is an exception thrown in another thread where it's not possible to determine whether the exception has caused the current exception or not.
      Returns:
      null if no such exception was thrown.