From b2005299e4311e5517ed131fe6a2dc10d2222bbb Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Sat, 30 Oct 2010 21:32:08 +0000 Subject: [PATCH] Make JsonSyntaxException public, so clients can differentiate between IO problems and malformed JSON. --- .../com/google/gson/stream/JsonReader.java | 7 ----- .../gson/stream/JsonSyntaxException.java | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 gson/src/main/java/com/google/gson/stream/JsonSyntaxException.java diff --git a/gson/src/main/java/com/google/gson/stream/JsonReader.java b/gson/src/main/java/com/google/gson/stream/JsonReader.java index 1a6811c4..09283100 100644 --- a/gson/src/main/java/com/google/gson/stream/JsonReader.java +++ b/gson/src/main/java/com/google/gson/stream/JsonReader.java @@ -1115,11 +1115,4 @@ public final class JsonReader implements Closeable { snippet.append(buffer, pos, afterPos); return snippet; } - - @SuppressWarnings("serial") - private static class JsonSyntaxException extends IOException { - private JsonSyntaxException(String s) { - super(s); - } - } } diff --git a/gson/src/main/java/com/google/gson/stream/JsonSyntaxException.java b/gson/src/main/java/com/google/gson/stream/JsonSyntaxException.java new file mode 100644 index 00000000..af3d65f5 --- /dev/null +++ b/gson/src/main/java/com/google/gson/stream/JsonSyntaxException.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.gson.stream; + +import java.io.IOException; + +/** + * Thrown when a reader encounters malformed JSON. Some syntax errors can be + * ignored by calling {@link JsonReader#setLenient(boolean)}. + */ +public final class JsonSyntaxException extends IOException { + public JsonSyntaxException(String s) { + super(s); + } +}