1 57 58 package org.apache.soap; 59 60 66 public class SOAPException extends Exception { 67 private String faultCode; 68 private Throwable targetException; 69 70 public SOAPException (String faultCode, String msg) { 71 super (Utils.cleanString (msg)); 72 this.faultCode = Utils.cleanString (faultCode); 73 } 74 75 public SOAPException (String faultCode, String msg, 76 Throwable targetException) { 77 this (faultCode, msg); 78 this.targetException = targetException; 79 } 80 81 public void setFaultCode (String faultCode) { 82 this.faultCode = Utils.cleanString (faultCode); 83 } 84 85 public String getFaultCode () { 86 return faultCode; 87 } 88 89 public void setTargetException (Throwable targetException) { 90 this.targetException = targetException; 91 } 92 93 public Throwable getTargetException () { 94 return targetException; 95 } 96 97 public Throwable getRootException() { 98 return targetException != null ? targetException : this; 99 } 100 101 public String getMessage () { 102 String superMsg = super.getMessage (); 103 String targetMsg = (targetException != null) 104 ? targetException.getMessage () 105 : null; 106 String msg = ((superMsg == null || superMsg.equals ("")) 107 && (targetMsg != null && !targetMsg.equals (""))) 108 ? targetMsg 109 : superMsg; 110 111 if (msg == null || msg.equals ("")) { 112 msg = (targetException != null) 113 ? targetException.toString() 114 : this.toString(); 115 } 116 117 return msg; 118 } 119 120 public String toString () { 121 return "[SOAPException: faultCode=" + faultCode + "; msg=" + 122 super.getMessage () + ((targetException != null) 123 ? ("; targetException=" + targetException) : "") + "]"; 124 } 125 } 126 | Popular Tags |