Created
September 15, 2019 05:45
-
-
Save altimmons/49a8f00da84af45ccca211af7c90d62e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A handler for printing stack traces in the Log, which doesn't like pure | |
* stack traces, just string elements. I am sure there is an easier way. | |
* | |
* @param ste - the stack trace element. | |
* @return A formatted string of the last [STACK_TRACE_LEN] stack trace | |
* elements. | |
*/ | |
public static String stackTraceConv( StackTraceElement[] ste ){ | |
StringBuilder sb = new StringBuilder(); | |
for( int i = 0 ; i < Sys.STACK_TRACE_LEN ; i++ ){ | |
if( ste[ i ] != null ) sb | |
.append( i ) | |
.append( ".) " ) | |
.append( ste[ i ].toString() ) | |
.append( "\n" ); | |
} | |
return sb.toString(); | |
} | |
/** | |
* A handler for printing stack traces in the Log, which doesn't like pure | |
* stack traces, just string elements. I am sure there is an easier way. | |
* | |
* @param e - the Exception which occurs. | |
* @return A formatted string of the last [STACK_TRACE_LEN] stack trace | |
* elements. | |
*/ | |
public static String exceptionConv( Exception e ){ | |
LOG.fine( "exceptionConv Method called." ); | |
StringBuilder sb = new StringBuilder( "EXCEPTION!: " ); | |
sb | |
.append( e.toString() ) | |
.append( "\n" ); | |
StackTraceElement[] ste = e.getStackTrace(); | |
for( int i = 0 ; i < Sys.STACK_TRACE_LEN ; i++ ){ | |
if( ste[ i ] != null ) sb | |
.append( i ) | |
.append( ".) " ) | |
.append( ste[ i ].toString() ) | |
.append( "\n" ); | |
} | |
return sb.toString(); | |
} | |
/** | |
* A handler for printing stack traces in the Log, which doesn't like pure | |
* stack traces, just string elements. I am sure there is an easier way. | |
* | |
* @param t - the Exception which occurs. | |
* @return A formatted string of the last [STACK_TRACE_LEN] stack trace | |
* elements. | |
*/ | |
public static String throwableCon( Throwable t ){ | |
StringBuilder sb = new StringBuilder( "EXCEPTION!: " ); | |
sb | |
.append( t.toString() ) | |
.append( "\n" ); | |
StackTraceElement[] ste = t.getStackTrace(); | |
for( int i = 0 ; i < Sys.STACK_TRACE_LEN ; i++ ){ | |
if( ste[ i ] != null ) sb | |
.append( i ) | |
.append( ".) " ) | |
.append( ste[ i ].toString() ) | |
.append( "\n" ); | |
} | |
return sb.toString(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment