1 18 19 package sync4j.syncclient.spap; 20 21 27 public class AssetManagementException extends Exception { 28 29 30 private Asset asset = null; 31 private String idAsset = null; 32 private Throwable cause = null; 33 34 36 42 public AssetManagementException(String message) { 43 super(message); 44 } 45 46 54 public AssetManagementException(String message, Throwable cause) { 55 this(message); 56 this.cause = cause; 57 } 58 59 66 public AssetManagementException(Asset asset, String message) { 67 super(message); 68 this.asset = asset; 69 } 70 71 78 public AssetManagementException(Asset asset, String message, Throwable cause) { 79 this(asset,message); 80 this.cause = cause; 81 } 82 83 89 public AssetManagementException(String idAsset, String message) { 90 super(message); 91 this.idAsset = idAsset; 92 } 93 94 101 public AssetManagementException(String idAsset, String message, Throwable cause) { 102 this(idAsset,message); 103 this.cause = cause; 104 } 105 106 110 public String toString() { 111 StringBuffer message = new StringBuffer (); 112 if (asset!=null) { 113 message.append(super.toString()); 114 message.append(" (id: "); 115 message.append(asset.getId()); 116 message.append(", manufacturer: "); 117 message.append(asset.getManufacturer()); 118 message.append(", name: "); 119 message.append(asset.getName()); 120 message.append(")"); 121 } else if (idAsset != null) { 122 message.append(super.toString()); 123 message.append(" (id: "); 124 message.append(idAsset); 125 message.append(")"); 126 } else { 127 message.append(super.toString()); 128 } 129 130 return message.toString(); 131 } 132 133 136 public void printStackTrace() { 137 super.printStackTrace(); 138 if (cause != null) { 139 System.err.println("Caused by:"); 140 cause.printStackTrace(); 141 } 142 } 143 144 } | Popular Tags |