Add Sone exception.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneException.java
1 /*
2  * FreenetSone - SoneException.java - Copyright © 2010 David Roden
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 net.pterodactylus.sone.core;
19
20 /**
21  * A Sone exception.
22  *
23  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
24  */
25 public class SoneException extends Exception {
26
27         /**
28          * Defines the different error. This is an enum instead of custom exceptions
29          * to keep the number of exceptions down. Specialized exceptions might still
30          * exist, though.
31          */
32         public static enum Type {
33
34                 /** An invalid URI was specified. */
35                 INVALID_URI
36         }
37
38         /** The type of the exception. */
39         private final Type type;
40
41         /**
42          * Creates a new Sone exception.
43          *
44          * @param type
45          *            The type of the occured error
46          */
47         public SoneException(Type type) {
48                 this.type = type;
49         }
50
51         /**
52          * Creates a new Sone exception.
53          *
54          * @param type
55          *            The type of the occured error
56          * @param message
57          *            The message of the exception
58          */
59         public SoneException(Type type, String message) {
60                 super(message);
61                 this.type = type;
62         }
63
64         /**
65          * Creates a new Sone exception.
66          *
67          * @param type
68          *            The type of the occured error
69          * @param cause
70          *            The cause of the exception
71          */
72         public SoneException(Type type, Throwable cause) {
73                 super(cause);
74                 this.type = type;
75         }
76
77         /**
78          * Creates a new Sone exception.
79          *
80          * @param type
81          *            The type of the occured error
82          * @param message
83          *            The message of the exception
84          * @param cause
85          *            The cause of the exception
86          */
87         public SoneException(Type type, String message, Throwable cause) {
88                 super(message, cause);
89                 this.type = type;
90         }
91
92         //
93         // ACCESSORS
94         //
95
96         /**
97          * Returns the type of this exception.
98          *
99          * @return The type of this exception (may be {@code null})
100          */
101         public Type getType() {
102                 return type;
103         }
104
105 }