00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 package org.openmobileis.common.util.exception;
00031
00032 import java.io.*;
00033
00034 import org.openmobileis.common.util.OpenMISSerializable;
00035 import org.openmobileis.common.util.log.*;
00036
00055
00056 public abstract class OpenMISException extends Exception implements OpenMISSerializable {
00057 static final long serialVersionUID = 5521257935120563452L;
00058
00059
00060 private Throwable associatedException = null;
00061
00062 private int priority;
00063
00064 public OpenMISException(String msg) {
00065 super(msg);
00066 priority = LogPriorities.ERROR;
00067 }
00068
00069 public OpenMISException(String msg, int logPriority) {
00070 super(msg);
00071 priority = logPriority;
00072 }
00073
00074 public OpenMISException(String msg, Throwable t) {
00075 super(msg);
00076 priority = LogPriorities.ERROR;
00077 associatedException = t;
00078 }
00079
00080 public OpenMISException(String msg, Throwable t, int logPriority) {
00081 super(msg);
00082 priority = logPriority;
00083 associatedException = t;
00084 }
00085
00086 public OpenMISException() {
00087 super();
00088 priority = LogPriorities.ERROR;
00089 }
00090
00091 public OpenMISException(int logPriority) {
00092 super();
00093 priority = logPriority;
00094 }
00095
00096 public OpenMISException(Throwable t) {
00097 this(t.getMessage());
00098 associatedException = t;
00099 }
00100
00101 public OpenMISException(Throwable t, int logPriority) {
00102 this(t.getMessage());
00103 associatedException = t;
00104 priority = logPriority;
00105 }
00106
00107 public Throwable getNestedError() {
00108 return associatedException;
00109 }
00110
00111 public final int getPriority() {
00112 return priority;
00113 }
00114
00115 public void printStackTrace() {
00116 printStackTrace(System.err);
00117 }
00118
00119 public void printStackTrace(PrintStream ps) {
00120 printStackTrace(new PrintWriter(new OutputStreamWriter(ps)));
00121 }
00122
00123 public void printStackTrace(PrintWriter writer) {
00124 if (null != getNestedError()) {
00125 getNestedError().printStackTrace(writer);
00126 }
00127
00128
00129 writer.println(this.getClass().getName() + "; service="
00130 + LogServices.toString(getService()) + "; priority="
00131 + LogPriorities.toString(getPriority()) + " : " + getMessage());
00132
00133 super.printStackTrace(writer);
00134 writer.flush();
00135 }
00136
00143 public abstract int getService();
00144 }