1 24 package org.objectweb.jalisto.se.exception.remote; 25 26 import org.objectweb.jalisto.se.exception.JalistoException; 27 28 import java.io.StringWriter ; 29 import java.io.PrintWriter ; 30 import java.io.PrintStream ; 31 32 public class RemoteException extends JalistoException { 33 34 public RemoteException() { 35 } 36 37 public RemoteException(String s) { 38 super(s); 39 remoteMessage = s; 40 } 41 42 public RemoteException(String s, Throwable throwable) { 43 super(s); 44 remoteMessage = s; 45 manageThrowable(throwable); 46 } 47 48 public RemoteException(Throwable throwable) { 49 super(); 50 manageThrowable(throwable); 51 remoteMessage = throwable.getMessage(); 52 } 53 54 private void manageThrowable(Throwable throwable) { 55 StringWriter sw = new StringWriter (); 56 throwable.printStackTrace(new PrintWriter (sw)); 57 sw.flush(); 58 stackTrace = sw.toString(); 59 } 60 61 public void printStackTrace() { 62 super.printStackTrace(); 63 if (stackTrace != null) { 64 System.err.println("remotly caused by : "+stackTrace); 65 } 66 } 67 68 public void printStackTrace(PrintStream printStream) { 69 super.printStackTrace(printStream); 70 if (stackTrace != null) { 71 printStream.println("remotly caused by : "+stackTrace); 72 } 73 } 74 75 public void printStackTrace(PrintWriter printWriter) { 76 super.printStackTrace(printWriter); 77 if (stackTrace != null) { 78 printWriter.println("remotly caused by : "+stackTrace); 79 } 80 } 81 82 public String getMessage() { 83 if (remoteMessage == null) { 84 return super.getMessage(); 85 } else { 86 return remoteMessage; 87 } 88 } 89 90 private String stackTrace; 91 private String remoteMessage; 92 } 93 | Popular Tags |