001/* 002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 003 * 004 * Copyright (c) 2012-2018 Oracle and/or its affiliates. All rights reserved. 005 * 006 * The contents of this file are subject to the terms of either the GNU 007 * General Public License Version 2 only ("GPL") or the Common Development 008 * and Distribution License("CDDL") (collectively, the "License"). You 009 * may not use this file except in compliance with the License. You can 010 * obtain a copy of the License at 011 * https://oss.oracle.com/licenses/CDDL+GPL-1.1 012 * or LICENSE.txt. See the License for the specific 013 * language governing permissions and limitations under the License. 014 * 015 * When distributing the software, include this License Header Notice in each 016 * file and include the License file at LICENSE.txt. 017 * 018 * GPL Classpath Exception: 019 * Oracle designates this particular file as subject to the "Classpath" 020 * exception as provided by Oracle in the GPL Version 2 section of the License 021 * file that accompanied this code. 022 * 023 * Modifications: 024 * If applicable, add the following below the License Header, with the fields 025 * enclosed by brackets [] replaced by your own identifying information: 026 * "Portions Copyright [year] [name of copyright owner]" 027 * 028 * Contributor(s): 029 * If you wish your version of this file to be governed by only the CDDL or 030 * only the GPL Version 2, indicate your decision by adding "[Contributor] 031 * elects to include this software in this distribution under the [CDDL or GPL 032 * Version 2] license." If you don't indicate a single choice of license, a 033 * recipient has the option to distribute your version of this file under 034 * either the CDDL, the GPL Version 2 or to extend the choice of license to 035 * its licensees as provided above. However, if you add GPL Version 2 code 036 * and therefore, elected the GPL Version 2 license, then the option applies 037 * only if the new code is made subject to such option by the copyright 038 * holder. 039 */ 040 041package javax.json.stream; 042 043import javax.json.JsonException; 044 045/** 046 * {@code JsonParsingException} is used when an incorrect JSON is 047 * being parsed. 048 * 049 * <EMBED CLASS='external-html' DATA-FILE-ID=LICENSE DATA-CIETName=JsonParsingException> 050 */ 051@SuppressWarnings("serial") 052public class JsonParsingException extends JsonException { 053 054 private final JsonLocation location; 055 056 /** 057 * Constructs a new runtime exception with the specified detail message. 058 * The cause is not initialized, and may subsequently be initialized by a 059 * call to {@link #initCause}. 060 * 061 * @param message the detail message. The detail message is saved for 062 * later retrieval by the {@link #getMessage()} method. 063 * @param location the location of the incorrect JSON 064 */ 065 public JsonParsingException(String message, JsonLocation location) { 066 super(message); 067 this.location = location; 068 } 069 070 /** 071 * Constructs a new runtime exception with the specified detail message and 072 * cause. 073 * 074 * <BR /><BR />Note that the detail message associated with 075 * {@code cause} is <i>not</i> automatically incorporated in 076 * this runtime exception's detail message. 077 * 078 * @param message the detail message (which is saved for later retrieval 079 * by the {@link #getMessage()} method). 080 * @param cause the cause (which is saved for later retrieval by the 081 * {@link #getCause()} method). (A <code>null</code> value is 082 * permitted, and indicates that the cause is nonexistent or 083 * unknown.) 084 * @param location the location of the incorrect JSON 085 */ 086 public JsonParsingException(String message, Throwable cause, JsonLocation location) { 087 super(message, cause); 088 this.location = location; 089 } 090 091 /** 092 * Return the location of the incorrect JSON. 093 * 094 * @return the non-null location of the incorrect JSON 095 */ 096 public JsonLocation getLocation() { 097 return location; 098 } 099 100} 101