1 29 package net.sourceforge.groboutils.mbtf.v1.engine; 30 31 32 import java.io.StringWriter ; 33 import java.io.PrintWriter ; 34 35 import net.sourceforge.groboutils.mbtf.v1.IError; 36 import net.sourceforge.groboutils.mbtf.v1.IPathHistory; 37 38 39 46 public class ErrorImpl implements IError 47 { 48 private IPathHistory pathHistory; 49 private Throwable err; 50 private String msg; 51 52 53 public ErrorImpl( String msg, Throwable err, IPathHistory ph ) 54 { 55 this.msg = msg; 56 this.err = err; 57 this.pathHistory = ph; 58 } 59 60 61 66 public IPathHistory getPathHistory() 67 { 68 return this.pathHistory; 69 } 70 71 72 78 public Throwable getThrowable() 79 { 80 return this.err; 81 } 82 83 84 89 public String getMessage() 90 { 91 return this.msg; 92 } 93 94 95 public String toString() 96 { 97 String ls = System.getProperty("line.separator"); 98 if (ls == null) 99 { 100 ls = "\n"; 101 } 102 StringBuffer sb = new StringBuffer ( "ERROR: " ); 103 if (getMessage() != null) 104 { 105 sb.append( getMessage() ); 106 sb.append( ":" ); 107 } 108 sb.append( ls ); 109 if (getThrowable() != null) 110 { 111 StringWriter sw = new StringWriter (); 112 PrintWriter pw = new PrintWriter ( sw ); 113 getThrowable().printStackTrace( pw ); 114 115 sb.append( sw.toString() ); 116 } 117 if (getPathHistory() != null) 118 { 119 sb.append("at").append( ls ).append( getPathHistory() ); 120 } 121 122 return sb.toString(); 123 } 124 } 125 126 | Popular Tags |