Class Exceptions

  • Direct Known Subclasses:
    PersistenceExceptions

    public class Exceptions
    extends java.lang.Object
    Utility methods for externalizing and handling exceptions.
    Since:
    0.2.5
    Author:
    Marc Prud'hommeaux
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.Throwable[] EMPTY_THROWABLES  
    • Constructor Summary

      Constructors 
      Constructor Description
      Exceptions()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void printNestedThrowables​(ExceptionInfo e, java.io.PrintStream out)
      Print the stack trace of the exception's nested throwables.
      static void printNestedThrowables​(ExceptionInfo e, java.io.PrintWriter out)
      Print the stack trace of the exception's nested throwables.
      static java.lang.Object replaceFailedObject​(java.lang.Object ob)
      Convert the specified failed object into a serializable object for when we are serializing an Exception.
      static java.lang.Throwable[] replaceNestedThrowables​(java.lang.Throwable[] nested)
      Convert the specified throwables into a serialzable array.
      static java.lang.String toClassName​(java.lang.Class<?> cls)  
      static java.lang.String toClassNames​(java.util.Collection<? extends java.lang.Class<?>> classes)  
      static java.lang.String toString​(java.lang.Object ob)
      Safely stringify the given object.
      static java.lang.String toString​(java.util.Collection failed)
      Safely stringify the given objects.
      static java.lang.String toString​(ExceptionInfo e)
      Stringify the given exception.
      • Methods inherited from class java.lang.Object

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

      • EMPTY_THROWABLES

        public static final java.lang.Throwable[] EMPTY_THROWABLES
    • Constructor Detail

      • Exceptions

        public Exceptions()
    • Method Detail

      • toString

        public static java.lang.String toString​(java.lang.Object ob)
        Safely stringify the given object.
      • toString

        public static java.lang.String toString​(java.util.Collection failed)
        Safely stringify the given objects.
      • toString

        public static java.lang.String toString​(ExceptionInfo e)
        Stringify the given exception.
      • printNestedThrowables

        public static void printNestedThrowables​(ExceptionInfo e,
                                                 java.io.PrintStream out)
        Print the stack trace of the exception's nested throwables.
      • printNestedThrowables

        public static void printNestedThrowables​(ExceptionInfo e,
                                                 java.io.PrintWriter out)
        Print the stack trace of the exception's nested throwables.
      • replaceFailedObject

        public static java.lang.Object replaceFailedObject​(java.lang.Object ob)
        Convert the specified failed object into a serializable object for when we are serializing an Exception. It will try the following:
        • if the object can be serialized, return the object itself
        • if the object has a serializable oid, return the oid
        • if the object has a non-serializable oid, return the oid's toString and the object class
        • return the object's toString
        Parameters:
        ob - the object to convert
        Returns:
        some serialized representation of the object
      • replaceNestedThrowables

        public static java.lang.Throwable[] replaceNestedThrowables​(java.lang.Throwable[] nested)
        Convert the specified throwables into a serialzable array. If any of the nested throwables cannot be serialized, they will be converted into a Exception with the original message.
      • toClassName

        public static java.lang.String toClassName​(java.lang.Class<?> cls)
      • toClassNames

        public static java.lang.String toClassNames​(java.util.Collection<? extends java.lang.Class<?>> classes)