1 26 27 28 package org.objectweb.mobilitools.smi.api; 29 30 31 import java.io.*; 32 33 34 39 public class BadOperation extends Exception 40 { 41 42 static public final int OTHER = 0; 43 44 static public final int REJECTED = 1; 45 46 static public final int INFRASTRUCTURE = 2; 47 48 static public final int DESTINATION = 3; 49 50 static public final int CLASSFAULT = 4; 51 52 static public final int UNKNOWNAGENT = 5; 53 54 static public final int SERIALIZATION = 6; 55 56 static public final int RUNNING = 7; 57 58 static public final int SUSPENDED = 8; 59 60 static public final int INSTANTIATION = 9; 61 62 static public final int AGENTTYPE = 10; 63 64 static public final int INVALIDNAME = 11; 65 66 static public final int UNKNOWNAGENCY = 13; 67 68 static public final int RETRY = 14; 69 70 71 72 protected int reason = OTHER; 73 74 protected String message = null; 75 76 protected Exception nested = null; 77 78 79 84 public BadOperation(int reason, String message) 85 { 86 this(reason, message, null); 87 } 88 89 90 96 public BadOperation(int reason, String message, Exception nested) 97 { 98 this.reason = reason; 99 this.message = message; 100 this.nested = nested; 101 } 102 103 104 107 public int getReason() 108 { 109 return reason; 110 } 111 112 113 116 public String getMessage() 117 { 118 return message; 119 } 120 121 122 125 public Exception getNested() 126 { 127 return nested; 128 } 129 130 131 134 public String toString() 135 { 136 return "BadOperation exception: " + message + " (error code " + String.valueOf(reason) + (nested == null ? ")" : ", nested exception: " + nested + ")"); 137 } 138 139 140 144 public void printAllStackTrace() 145 { 146 printAllStackTrace(System.err); 147 } 148 149 150 155 public void printAllStackTrace(PrintStream s) 156 { 157 printStackTrace(s); 158 if (nested != null) 159 { 160 s.println("NESTED EXCEPTION'S STACK TRACE BELOW:"); 161 nested.printStackTrace(s); 162 } 163 } 164 165 166 171 public void printAllStackTrace(PrintWriter w) 172 { 173 printStackTrace(w); 174 if (nested != null) 175 { 176 w.println("NESTED EXCEPTION'S STACK TRACE BELOW:"); 177 nested.printStackTrace(w); 178 } 179 } 180 } 181 | Popular Tags |