Debian Codegraph @

src/jakarta/json/stream/JsonParsingException.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2012, 2022 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
17 package jakarta.json.stream;
18
19 import jakarta.json.JsonException;
20
21 /**
22 * {@code JsonParsingException} is used when an incorrect JSON is
23 * being parsed.
24 */
25 public class JsonParsingException extends JsonException {
26
27 /** for serialization */
28 private static final long serialVersionUID = 9073566598484238797L;
29
30 /**
31 * The location of the incorrect JSON.
32 */
33 private transient final JsonLocation location;
34
35 /**
36 * Constructs a new runtime exception with the specified detail message.
37 * The cause is not initialized, and may subsequently be initialized by a
38 * call to {@link #initCause}.
39 *
40 * @param message the detail message. The detail message is saved for
41 * later retrieval by the {@link #getMessage()} method.
42 * @param location the location of the incorrect JSON
43 */
44 public JsonParsingException(String message, JsonLocation location) {
45 super(message);
46 this.location = location;
47 }
48
49 /**
50 * Constructs a new runtime exception with the specified detail message and
51 * cause. <p>Note that the detail message associated with
52 * {@code cause} is <i>not</i> automatically incorporated in
53 * this runtime exception's detail message.
54 *
55 * @param message the detail message (which is saved for later retrieval
56 * by the {@link #getMessage()} method).
57 * @param cause the cause (which is saved for later retrieval by the
58 * {@link #getCause()} method). (A <code>null</code> value is
59 * permitted, and indicates that the cause is nonexistent or
60 * unknown.)
61 * @param location the location of the incorrect JSON
62 */
63 public JsonParsingException(String message, Throwable cause, JsonLocation location) {
64 super(message, cause);
65 this.location = location;
66 }
67
68 /**
69 * Return the location of the incorrect JSON.
70 *
71 * @return the non-null location of the incorrect JSON
72 */
73 public JsonLocation getLocation() {
74 return location;
75 }
76
77 }
78