1 16 package scriptella.spi; 17 18 import scriptella.core.SystemException; 19 20 import java.util.LinkedHashSet ; 21 import java.util.Set ; 22 23 24 31 public abstract class ProviderException extends SystemException { 32 private Set <String > errorCodes = new LinkedHashSet <String >(); 33 private String errorStatement; 34 35 public ProviderException() { 36 } 37 38 public ProviderException(String message) { 39 super(message); 40 } 41 42 public ProviderException(String message, Throwable cause) { 43 super(message, cause); 44 } 45 46 public ProviderException(Throwable cause) { 47 super(cause); 48 } 49 50 57 public Set <String > getErrorCodes() { 58 return errorCodes; 59 } 60 61 67 public ProviderException addErrorCode(String errorCode) { 68 errorCodes.add(errorCode); 69 return this; 70 } 71 72 78 protected ProviderException setErrorStatement(String errStmt) { 79 this.errorStatement = errStmt; 80 return this; 81 } 82 83 90 public Throwable getNativeException() { 91 return getCause(); 92 } 93 94 99 public String getErrorStatement() { 100 return errorStatement; 101 } 102 103 108 public abstract String getProviderName(); 109 110 public String toString() { 111 StringBuilder res = new StringBuilder (super.toString()); 112 String es = getErrorStatement(); 113 if (es != null) { 114 res.append(". Error statement: ").append(es); 115 } 116 Set <String > codes = getErrorCodes(); 117 if (codes != null && !codes.isEmpty()) { 118 res.append(". Error codes: ").append(codes); 119 } 120 return res.toString(); 121 122 } 123 124 125 } 126 | Popular Tags |