Class ExceptionContext

java.lang.Object
jmri.util.swing.ExceptionContext
Direct Known Subclasses:
UnexpectedExceptionContext

public class ExceptionContext extends Object
Wraps an Exception and allows extra contextual information to be added, such as what was happening at the time of the Exception, and a hint as to what the user might do to correct the problem. Also implements a number of methods to format the data of an Exception.
  • Field Details

  • Constructor Details

    • ExceptionContext

      Create a new Exception Context.
      Parameters:
      ex - the Throwable Exception which has occurred.
      operation - An Operation which was taking place at the time of the Exception. Use empty String if unknown.
      hint - A hint as to what might have caused the Exception. Use empty String if unknown.
  • Method Details

    • getException

      Get the Exception being wrapped.
      Returns:
      the Exception.
    • getPreface

      public String getPreface()
      Used to give a more friendly message.
      Returns:
      the Preface String.
    • getOperation

      public String getOperation()
      Get what was happening when the exception occurred.
      Returns:
      empty String if unknown.
    • getHint

      Get suggestion to the user to correct the problem.
      Returns:
      empty string if no hint, else the hint text.
    • getTitle

      public String getTitle()
      Get a String to use as the Title for this Context.
      Returns:
      Localised Exception message, truncated to 80 chars.
    • getSummary

      public String getSummary()
      Returns a user friendly summary of the Exception. Empty data is excluded.
      Returns:
      A string summary.
    • getStackTraceAsString

      public String getStackTraceAsString(int maxLevels)
      Returns up to the given number of stack trace elements concatenated into one string.
      Parameters:
      maxLevels - The number of stack trace elements to return.
      Returns:
      A string stack trace.
    • getStackTraceString

      Get the Full Stack Trace String.
      Returns:
      unabridged Stack Trace String.
    • getClipboardString

      public String getClipboardString(boolean includeSysInfo)
      Get a String form of this Context for use in pasting to Clipboard.
      Parameters:
      includeSysInfo - true to include System Information, false for just the Exception details.
      Returns:
      String for use in Clipboard text.