public static ErrorDescription create ( Throwable ex , String correlationId ) { ErrorDescription description = new ErrorDescription ( ) ; description . setType ( ex . getClass ( ) . getCanonicalName ( ) ) ; description . setCategory ( ErrorCategory . Unknown ) ; description . setStatus ( 500 ) ; description . setCode ( "Unknown" ) ; description . setMessage ( ex . getMessage ( ) ) ; Throwable t = ex . getCause ( ) ; description . setCause ( t != null ? t . toString ( ) : null ) ; StackTraceElement [ ] ste = ex . getStackTrace ( ) ; StringBuilder builder = new StringBuilder ( ) ; if ( ste != null ) { for ( int i = 0 ; i < ste . length ; i ++ ) { if ( builder . length ( ) > 0 ) builder . append ( " " ) ; builder . append ( ste [ i ] . toString ( ) ) ; } } description . setStackTrace ( builder . toString ( ) ) ; description . setCorrelationId ( correlationId ) ; return description ; }
Creates a serializable ErrorDescription from throwable object with unknown error category .