1 40 41 package org.dspace.content.packager; 42 43 import java.io.PrintWriter ; 44 import java.io.StringWriter ; 45 46 import org.apache.log4j.Logger; 47 48 57 public class PackageException extends Exception 58 { 59 63 public PackageException() 64 { 65 super(); 66 } 67 68 public PackageException(String message) 69 { 70 super(message); 71 } 72 73 public PackageException(Throwable cause) 74 { 75 super(cause); 76 } 77 78 82 public PackageException(String message, Throwable cause) 83 { 84 super(message, cause); 85 } 86 87 91 public void log(Logger log) 92 { 93 log.error(toString()); 94 95 Throwable cause = getCause(); 96 if (cause != null) 97 { 98 if (cause.getCause() != null) 99 cause = cause.getCause(); 100 StringWriter sw = new StringWriter (); 101 cause.printStackTrace(new PrintWriter (sw)); 102 log.error(sw.toString()); 103 } 104 } 105 106 public String toString() 107 { 108 String base = getClass().getName() + ": " + getMessage(); 109 return (getCause() == null) ? base : 110 base + ", Reason: "+getCause().toString(); 111 } 112 } 113 | Popular Tags |