1 15 package org.apache.hivemind; 16 17 25 26 public class ApplicationRuntimeException extends RuntimeException implements Locatable 27 { 28 private static final long serialVersionUID = 1L; 29 30 private Throwable _rootCause; 31 32 private transient Location _location; 33 34 private transient Object _component; 35 36 public ApplicationRuntimeException(Throwable rootCause) 37 { 38 this(rootCause.getMessage(), rootCause); 39 } 40 41 public ApplicationRuntimeException(String message) 42 { 43 this(message, null, null, null); 44 } 45 46 public ApplicationRuntimeException(String message, Throwable rootCause) 47 { 48 this(message, null, null, rootCause); 49 } 50 51 public ApplicationRuntimeException(String message, Object component, Location location, 52 Throwable rootCause) 53 { 54 super(message); 55 56 _rootCause = rootCause; 57 _component = component; 58 59 _location = HiveMind.findLocation(new Object [] 60 { location, rootCause, component }); 61 } 62 63 public ApplicationRuntimeException(String message, Location location, Throwable rootCause) 64 { 65 this(message, null, location, rootCause); 66 } 67 68 public Throwable getRootCause() 69 { 70 return _rootCause; 71 } 72 73 public Location getLocation() 74 { 75 return _location; 76 } 77 78 public Object getComponent() 79 { 80 return _component; 81 } 82 83 88 public Throwable getCause() 89 { 90 return _rootCause; 91 } 92 93 100 public String toString() 101 { 102 if (_location == null) 103 return super.toString(); 104 105 StringBuffer buffer = new StringBuffer (super.toString()); 106 buffer.append(" ["); 107 buffer.append(_location); 108 buffer.append("]"); 109 110 return buffer.toString(); 111 } 112 } | Popular Tags |