Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JThequeError |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.error; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | /** | |
20 | * An error. | |
21 | * | |
22 | * @author Baptiste Wicht | |
23 | */ | |
24 | public class JThequeError { | |
25 | private final String message; | |
26 | private Throwable exception; | |
27 | private String details; | |
28 | ||
29 | /** | |
30 | * Construct a new Error with a simple message. | |
31 | * | |
32 | * @param message The message of the error. | |
33 | */ | |
34 | JThequeError(String message) { | |
35 | 0 | super(); |
36 | ||
37 | 0 | this.message = message; |
38 | 0 | } |
39 | ||
40 | /** | |
41 | * Construct a new Error with a message and some details. | |
42 | * | |
43 | * @param message The message of the error. | |
44 | * @param details Some details about the error. | |
45 | */ | |
46 | JThequeError(String message, String details) { | |
47 | 0 | this(message); |
48 | ||
49 | 0 | this.details = details; |
50 | 0 | } |
51 | ||
52 | /** | |
53 | * Construct a new Error from an existing exception. The message of the error will be the message | |
54 | * of the exception. | |
55 | * | |
56 | * @param exception The existing exception. | |
57 | */ | |
58 | public JThequeError(Throwable exception) { | |
59 | 0 | this(exception.getMessage()); |
60 | ||
61 | 0 | this.exception = exception; |
62 | 0 | } |
63 | ||
64 | /** | |
65 | * Construct a new Error from an existing exception with a specific message. | |
66 | * | |
67 | * @param exception The exception to encapsulate in the error. | |
68 | * @param message The message. | |
69 | */ | |
70 | public JThequeError(Throwable exception, String message) { | |
71 | 0 | this(message); |
72 | ||
73 | 0 | this.exception = exception; |
74 | 0 | } |
75 | ||
76 | /** | |
77 | * Return the message of the error. | |
78 | * | |
79 | * @return The message of the error. | |
80 | */ | |
81 | public String getMessage() { | |
82 | 0 | return message; |
83 | } | |
84 | ||
85 | /** | |
86 | * Return the exception of the error. | |
87 | * | |
88 | * @return The exception who cause this error. | |
89 | */ | |
90 | public final Throwable getException() { | |
91 | 0 | return exception; |
92 | } | |
93 | ||
94 | /** | |
95 | * Return the details of the error. | |
96 | * | |
97 | * @return The details of the error. | |
98 | */ | |
99 | public String getDetails() { | |
100 | 0 | return details; |
101 | } | |
102 | } |