Fix wrong project name in file headers.
[Sone.git] / src / main / java / net / pterodactylus / sone / core / SoneException.java
1 /*
2  * Sone - 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 Sone name was specified. */
35                 INVALID_SONE_NAME,
36
37                 /** An invalid URI was specified. */
38                 INVALID_URI,
39
40         }
41
42         /** The type of the exception. */
43         private final Type type;
44
45         /**
46          * Creates a new Sone exception.
47          *
48          * @param type
49          *            The type of the occured error
50          */
51         public SoneException(Type type) {
52                 this.type = type;
53         }
54
55         /**
56          * Creates a new Sone exception.
57          *
58          * @param type
59          *            The type of the occured error
60          * @param message
61          *            The message of the exception
62          */
63         public SoneException(Type type, String message) {
64                 super(message);
65                 this.type = type;
66         }
67
68         /**
69          * Creates a new Sone exception.
70          *
71          * @param type
72          *            The type of the occured error
73          * @param cause
74          *            The cause of the exception
75          */
76         public SoneException(Type type, Throwable cause) {
77                 super(cause);
78                 this.type = type;
79         }
80
81         /**
82          * Creates a new Sone exception.
83          *
84          * @param type
85          *            The type of the occured error
86          * @param message
87          *            The message of the exception
88          * @param cause
89          *            The cause of the exception
90          */
91         public SoneException(Type type, String message, Throwable cause) {
92                 super(message, cause);
93                 this.type = type;
94         }
95
96         //
97         // ACCESSORS
98         //
99
100         /**
101          * Returns the type of this exception.
102          *
103          * @return The type of this exception (may be {@code null})
104          */
105         public Type getType() {
106                 return type;
107         }
108
109 }