1 package net.walend.somnifugi; 2 3 8 9 public class SomniRuntimeException 10 extends RuntimeException 11 { 12 private static final long serialVersionUID = 0L; 13 14 private SomniMessage lostMessage = null; 15 private SomniDestination destination = null; 16 17 protected SomniRuntimeException(String message) 18 { 19 super(message); 20 } 21 22 protected SomniRuntimeException(String message,SomniMessage lostMessage,SomniDestination destination) 23 { 24 super(message); 25 this.lostMessage = lostMessage; 26 this.destination = destination; 27 } 28 29 protected SomniRuntimeException(Throwable nester) 30 { 31 super(nester); 32 } 33 34 public SomniRuntimeException(String message, Throwable nester) 35 { 36 super(message,nester); 37 } 38 39 protected SomniRuntimeException(Throwable nester,SomniMessage lostMessage,SomniDestination destination) 40 { 41 super(nester); 42 this.lostMessage = lostMessage; 43 this.destination = destination; 44 } 45 46 public String getMessage() 47 { 48 if(destination==null) 49 { 50 return super.getMessage(); 51 } 52 else 53 { 54 StringBuffer buffy = new StringBuffer (); 55 56 buffy.append(super.getMessage()); 57 buffy.append(" while "); 58 buffy.append(destination.getName()); 59 buffy.append(" was trying to send "); 60 buffy.append(lostMessage.toString()); 61 62 return buffy.toString(); 63 } 64 } 65 66 public SomniMessage getLostMessage() 67 { 68 return lostMessage; 69 } 70 71 public SomniDestination getDestination() 72 { 73 return destination; 74 } 75 } 76 77 99 100 101 102 | Popular Tags |