Added an exception class to indicate IO Errors.

This commit is contained in:
Inderjeet Singh 2010-10-18 23:54:09 +00:00
parent 281ed6f866
commit 18a9205a04
3 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2008 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;
/**
* This exception is raised when Gson was unable to read an input stream
* or write to one.
*
* @author Inderjeet Singh
* @author Joel Leitch
*/
public final class JsonIOException extends JsonParseException {
public JsonIOException(String msg) {
super(msg);
}
public JsonIOException(String msg, Throwable cause) {
super(msg, cause);
}
/**
* Creates exception with the specified cause. Consider using
* {@link #JsonIOException(String, Throwable)} instead if you can describe what happened.
*
* @param cause root exception that caused this exception to be thrown.
*/
public JsonIOException(Throwable cause) {
super(cause);
}
}

View File

@ -29,7 +29,7 @@ package com.google.gson;
* @author Inderjeet Singh
* @author Joel Leitch
*/
public final class JsonParseException extends RuntimeException {
public class JsonParseException extends RuntimeException {
static final long serialVersionUID = -4086729973971783390L;
/**

View File

@ -18,6 +18,7 @@ package com.google.gson;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.EOFException;
import java.io.IOException;
import java.io.Writer;
@ -71,7 +72,7 @@ final class Streams {
if (e instanceof EOFException) {
return JsonNull.createJsonNull();
}
throw new JsonParseException(e);
throw new JsonIOException(e);
} catch (NumberFormatException e) {
throw new JsonParseException(e);
}