1 28 29 package com.caucho.naming; 30 31 import com.caucho.util.ExceptionWrapper; 32 33 import javax.naming.NamingException ; 34 import java.io.PrintStream ; 35 import java.io.PrintWriter ; 36 37 40 public class NamingExceptionWrapper extends NamingException 41 implements ExceptionWrapper { 42 private Throwable rootCause; 43 44 47 public NamingExceptionWrapper() 48 { 49 } 50 55 public NamingExceptionWrapper(String msg) 56 { 57 super(msg); 58 } 59 60 65 public NamingExceptionWrapper(Throwable rootCause) 66 { 67 super(rootCause.getMessage()); 68 69 this.rootCause = rootCause; 70 } 71 72 77 public Throwable getRootCause() 78 { 79 return rootCause; 80 } 81 82 85 public String getMessage() 86 { 87 if (rootCause != null) 88 return rootCause.getMessage(); 89 else 90 return super.getMessage(); 91 } 92 93 96 public void printStackTrace() 97 { 98 if (rootCause != null) 99 rootCause.printStackTrace(); 100 else 101 super.printStackTrace(); 102 } 103 104 107 public void printStackTrace(PrintStream os) 108 { 109 if (rootCause != null) 110 rootCause.printStackTrace(os); 111 else 112 super.printStackTrace(os); 113 } 114 115 118 public void printStackTrace(PrintWriter os) 119 { 120 if (rootCause != null) 121 rootCause.printStackTrace(os); 122 else 123 super.printStackTrace(os); 124 } 125 126 129 public String toString() 130 { 131 if (rootCause == null) 132 return super.toString(); 133 else 134 return getClass().getName() + ": " + rootCause; 135 } 136 } 137 138 | Popular Tags |