1    /*
2     * Copyright 2005 :torweg free software group
3     *
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program is distributed in the hope that it will be useful,
10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.service;
19   
20   /**
21    * Superclass for all Exceptions thrown by <em>pulse</em>.
22    * 
23    * @author Thomas Weber
24    * @version $Revision: 1392 $
25    */
26   public class PulseException extends RuntimeException {
27   
28       /**
29        * serial version UID for java.io.Serializable.
30        */
31       private static final long serialVersionUID = -4806503053984070478L;
32   
33       /**
34        * constructs a new exception with {@code null} as its detail message.
35        */
36       public PulseException() {
37           super();
38       }
39   
40       /**
41        * constructs a new exception with the specified detail message.
42        * 
43        * @param message
44        *            the message of the exception
45        */
46       public PulseException(final String message) {
47           super(message);
48       }
49   
50       /**
51        * constructs a new exception with the specified detail message and cause.
52        * 
53        * @param message
54        *            the message of the exception
55        * @param cause
56        *            the cause of the exception
57        */
58       public PulseException(final String message, final Throwable cause) {
59           super(message, cause);
60       }
61   
62       /**
63        * constructs a new exception with the specified cause.
64        * 
65        * @param cause
66        *            the cause of the exception
67        */
68       public PulseException(final Throwable cause) {
69           super(cause);
70       }
71   
72       /**
73        * @return returns the message of the exception and its cause
74        * @see java.lang.Throwable#getMessage()
75        */
76       public String getDetailMessage() {
77           if (getCause() == null) {
78               return super.getMessage();
79           }
80           return new StringBuilder(super.getMessage()).append("\nCaused by: ")
81                   .append(getCause().getClass().getCanonicalName()).append(' ')
82                   .append(getCause().getMessage()).toString();
83       }
84   
85   }
86