Wrap IOException into a JsonIoException instead of RuntimeException.

This commit is contained in:
Joel Leitch 2011-08-19 02:35:29 +00:00
parent ff88ac32f2
commit a85f9b81b0

View File

@ -16,18 +16,19 @@
package com.google.gson.internal.bind;
import com.google.gson.JsonElement;
import com.google.gson.JsonIOException;
import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import com.google.gson.JsonElement;
import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
public abstract class TypeAdapter<T> {
public abstract T read(JsonReader reader) throws IOException;
public abstract void write(JsonWriter writer, T value) throws IOException;
@ -63,7 +64,7 @@ public abstract class TypeAdapter<T> {
reader.setLenient(true);
return Streams.parse(reader);
} catch (IOException e) {
throw new RuntimeException(e);
throw new JsonIOException(e);
}
}
@ -77,7 +78,7 @@ public abstract class TypeAdapter<T> {
jsonReader.setLenient(true);
return read(jsonReader);
} catch (IOException e) {
throw new RuntimeException(e);
throw new JsonIOException(e);
}
}