public String printExceptionStackTrace ( Exception e , String level ) { // copying the exception stack trace in the string Writer writer = new StringWriter ( ) ; e . printStackTrace ( new PrintWriter ( writer ) ) ; String s = writer . toString ( ) ; switch ( level ) { case "debug" : this . messageHandler . debug ( this , "\n" + s + "\n" ) ; break ; case "info" : this . messageHandler . info ( this , "\n" + s + "\n" ) ; break ; case "warn" : this . messageHandler . warn ( this , "\n" + s + "\n" ) ; break ; case "error" : this . messageHandler . error ( this , "\n" + s + "\n" ) ; break ; } return s ; }
Builds the exception stack trace and prints it according to a level passed as argument .