1 16 17 package org.springframework.web.util; 18 19 import java.io.PrintStream ; 20 import java.io.PrintWriter ; 21 22 import javax.servlet.ServletException ; 23 24 import org.springframework.core.NestedExceptionUtils; 25 26 43 public class NestedServletException extends ServletException { 44 45 46 private static final long serialVersionUID = -5292377985529381145L; 47 48 49 53 public NestedServletException(String msg) { 54 super(msg); 55 } 56 57 63 public NestedServletException(String msg, Throwable cause) { 64 super(msg, cause); 65 } 66 67 68 72 public String getMessage() { 73 return NestedExceptionUtils.buildMessage(super.getMessage(), getRootCause()); 74 } 75 76 80 public void printStackTrace(PrintStream ps) { 81 Throwable cause = getRootCause(); 82 if (cause == null) { 83 super.printStackTrace(ps); 84 } 85 else { 86 ps.println(this); 87 ps.print("Caused by: "); 88 cause.printStackTrace(ps); 89 } 90 } 91 92 96 public void printStackTrace(PrintWriter pw) { 97 Throwable cause = getRootCause(); 98 if (cause == null) { 99 super.printStackTrace(pw); 100 } 101 else { 102 pw.println(this); 103 pw.print("Caused by: "); 104 cause.printStackTrace(pw); 105 } 106 } 107 108 } 109 | Popular Tags |