Make JsonSyntaxException public, so clients can differentiate between IO problems and malformed JSON.

This commit is contained in:
Jesse Wilson 2010-10-30 21:32:08 +00:00
parent 2b993d83b6
commit b2005299e4
2 changed files with 29 additions and 7 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}
}