KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > state > Err


1 package org.sapia.soto.state;
2
3 import org.apache.commons.lang.exception.ExceptionUtils;
4
5
6 /**
7  * Holds error information pertaining to a state's execution.
8  *
9  * @see org.sapia.soto.state.Result#error(Err)
10  *
11  * @author Yanick Duchesne
12  * <dl>
13  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
14  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
15  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
16  * </dl>
17  */

18 public class Err {
19   private String JavaDoc _msg;
20   private Throwable JavaDoc _err;
21
22   public Err(String JavaDoc msg, Throwable JavaDoc t) {
23     _msg = msg;
24     _err = t;
25   }
26
27   public Err(String JavaDoc msg) {
28     _msg = msg;
29   }
30
31   public Err(Throwable JavaDoc err) {
32     _err = err;
33   }
34
35   /**
36    * @return the <code>Throwable</code> that this instance holds, or <code>null</code>
37    * if this instance has no <code>Throwable</code>.
38    */

39   public Throwable JavaDoc getThrowable() {
40     return _err;
41   }
42
43   /**
44    * @return the <code>Throwable</code> kept within this instance as a string,
45    * or <code>null</code> if this instance holds not throwable.
46    */

47   public String JavaDoc getThrowableAsString() {
48     if (_err == null) {
49       return null;
50     }
51
52     return ExceptionUtils.getStackTrace(_err);
53   }
54
55   /**
56    * @return the error message that this instance holds.
57    */

58   public String JavaDoc getMsg() {
59     return _msg;
60   }
61 }
62
Popular Tags