Wrap IOException into a JsonIoException instead of RuntimeException.
This commit is contained in:
parent
ff88ac32f2
commit
a85f9b81b0
@ -16,18 +16,19 @@
|
|||||||
|
|
||||||
package com.google.gson.internal.bind;
|
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.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
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 class TypeAdapter<T> {
|
||||||
public abstract T read(JsonReader reader) throws IOException;
|
public abstract T read(JsonReader reader) throws IOException;
|
||||||
public abstract void write(JsonWriter writer, T value) throws IOException;
|
public abstract void write(JsonWriter writer, T value) throws IOException;
|
||||||
@ -63,7 +64,7 @@ public abstract class TypeAdapter<T> {
|
|||||||
reader.setLenient(true);
|
reader.setLenient(true);
|
||||||
return Streams.parse(reader);
|
return Streams.parse(reader);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new JsonIOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public abstract class TypeAdapter<T> {
|
|||||||
jsonReader.setLenient(true);
|
jsonReader.setLenient(true);
|
||||||
return read(jsonReader);
|
return read(jsonReader);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new JsonIOException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user