1 | /* This file is part of the project "Hilbert II" - http://www.qedeq.org |
2 | * |
3 | * Copyright 2000-2014, Michael Meyling <mime@qedeq.org>. |
4 | * |
5 | * "Hilbert II" is free software; you can redistribute |
6 | * it and/or modify it under the terms of the GNU General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This program 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 | |
16 | package org.qedeq.kernel.se.common; |
17 | |
18 | |
19 | /** |
20 | * Base class for all exceptions of this application. |
21 | * |
22 | * @author Michael Meyling |
23 | */ |
24 | public abstract class QedeqException extends Exception { |
25 | |
26 | /** Error code of this Exception. */ |
27 | private final int errorCode; |
28 | |
29 | /** |
30 | * Constructor. |
31 | * |
32 | * @param errorCode Error code of this message. |
33 | * @param message Error message. |
34 | * @param cause Detailed exception information. |
35 | */ |
36 | public QedeqException(final int errorCode, final String message, |
37 | final Throwable cause) { |
38 | super(message, cause); |
39 | this.errorCode = errorCode; |
40 | } |
41 | |
42 | /** |
43 | * Constructor. |
44 | * |
45 | * @param errorCode Error code of this message. |
46 | * @param message Error message. |
47 | */ |
48 | public QedeqException(final int errorCode, final String message) { |
49 | super(message); |
50 | this.errorCode = errorCode; |
51 | } |
52 | |
53 | /** |
54 | * Get error code. |
55 | * |
56 | * @return Error code. |
57 | */ |
58 | public int getErrorCode() { |
59 | return errorCode; |
60 | } |
61 | |
62 | public String toString() { |
63 | return getErrorCode() + ": " + getMessage(); |
64 | } |
65 | |
66 | } |