Class ExceptionContext

  • Direct Known Subclasses:
    UnexpectedExceptionContext

    public class ExceptionContext
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Exception _exception  
      protected java.lang.String _hint  
      protected java.lang.String _nl  
      protected java.lang.String _operation  
      protected java.lang.String _preface  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExceptionContext​(java.lang.Exception ex, java.lang.String operation, java.lang.String hint)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Exception getException()  
      java.lang.String getHint()  
      java.lang.String getOperation()  
      java.lang.String getPreface()  
      java.lang.String getStackTraceAsString​(int maxLevels)
      Returns up to the given number of stack trace elements concatenated into one string.
      java.lang.String getStackTraceString()  
      java.lang.String getSummary()
      Returns a user friendly summary of the Exception.
      java.lang.String getTitle()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _exception

        protected java.lang.Exception _exception
      • _preface

        protected java.lang.String _preface
      • _operation

        protected java.lang.String _operation
      • _hint

        protected java.lang.String _hint
      • _nl

        protected java.lang.String _nl
    • Constructor Detail

      • ExceptionContext

        public ExceptionContext​(java.lang.Exception ex,
                                java.lang.String operation,
                                java.lang.String hint)
    • Method Detail

      • getPreface

        public java.lang.String getPreface()
      • getHint

        public java.lang.String getHint()
      • getTitle

        public java.lang.String getTitle()
      • getSummary

        public java.lang.String getSummary()
        Returns a user friendly summary of the Exception. Empty parts are not included. (Maybe later?)
        Returns:
        A string summary.
      • getStackTraceAsString

        public java.lang.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.