1 16 17 package org.springframework.core; 18 19 import java.io.IOException ; 20 import java.io.PrintStream ; 21 import java.io.PrintWriter ; 22 23 38 public class NestedIOException extends IOException { 39 40 41 private Throwable cause; 42 43 44 48 public NestedIOException(String msg) { 49 super(msg); 50 } 51 52 58 public NestedIOException(String msg, Throwable cause) { 59 super(msg); 60 this.cause = cause; 61 } 62 63 64 67 public Throwable getCause() { 68 return (this.cause == this ? null : this.cause); 73 } 74 75 79 public String getMessage() { 80 return NestedExceptionUtils.buildMessage(super.getMessage(), getCause()); 81 } 82 83 87 public void printStackTrace(PrintStream ps) { 88 if (getCause() == null) { 89 super.printStackTrace(ps); 90 } 91 else { 92 ps.println(this); 93 ps.print("Caused by: "); 94 getCause().printStackTrace(ps); 95 } 96 } 97 98 102 public void printStackTrace(PrintWriter pw) { 103 if (getCause() == null) { 104 super.printStackTrace(pw); 105 } 106 else { 107 pw.println(this); 108 pw.print("Caused by: "); 109 getCause().printStackTrace(pw); 110 } 111 } 112 113 } 114 | Popular Tags |