]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (C) 2008 Google Inc. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | package com.google.gson; | |
18 | ||
19 | /** | |
20 | * This exception is raised if there is a serious issue that occurs during parsing of a Json | |
21 | * string. One of the main usages for this class is for the Gson infrastructure. If the incoming | |
22 | * Json is bad/malicious, an instance of this exception is raised. | |
23 | * | |
24 | * <p>This exception is a {@link RuntimeException} because it is exposed to the client. Using a | |
25 | * {@link RuntimeException} avoids bad coding practices on the client side where they catch the | |
26 | * exception and do nothing. It is often the case that you want to blow up if there is a parsing | |
27 | * error (i.e. often clients do not know how to recover from a {@link JsonParseException}.</p> | |
28 | * | |
29 | * @author Inderjeet Singh | |
30 | * @author Joel Leitch | |
31 | */ | |
32 | public class JsonParseException extends RuntimeException { | |
33 | static final long serialVersionUID = -4086729973971783390L; | |
34 | ||
35 | /** | |
36 | * Creates exception with the specified message. If you are wrapping another exception, consider | |
37 | * using {@link #JsonParseException(String, Throwable)} instead. | |
38 | * | |
39 | * @param msg error message describing a possible cause of this exception. | |
40 | */ | |
41 | public JsonParseException(String msg) { | |
42 | super(msg); | |
43 | } | |
44 | ||
45 | /** | |
46 | * Creates exception with the specified message and cause. | |
47 | * | |
48 | * @param msg error message describing what happened. | |
49 | * @param cause root exception that caused this exception to be thrown. | |
50 | */ | |
51 | public JsonParseException(String msg, Throwable cause) { | |
52 | super(msg, cause); | |
53 | } | |
54 | ||
55 | /** | |
56 | * Creates exception with the specified cause. Consider using | |
57 | * {@link #JsonParseException(String, Throwable)} instead if you can describe what happened. | |
58 | * | |
59 | * @param cause root exception that caused this exception to be thrown. | |
60 | */ | |
61 | public JsonParseException(Throwable cause) { | |
62 | super(cause); | |
63 | } | |
64 | } |