Merge pull request #168 from square/jw/cause

Propagate adapter method exception cause.
This commit is contained in:
Jesse Wilson
2016-06-06 09:08:47 -07:00

View File

@@ -64,8 +64,9 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new AssertionError(); throw new AssertionError();
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof IOException) throw (IOException) e.getCause(); Throwable cause = e.getCause();
throw new JsonDataException(e.getCause() + " at " + writer.getPath()); if (cause instanceof IOException) throw (IOException) cause;
throw new JsonDataException(cause + " at " + writer.getPath(), cause);
} }
} }
} }
@@ -82,8 +83,9 @@ final class AdapterMethodsFactory implements JsonAdapter.Factory {
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new AssertionError(); throw new AssertionError();
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof IOException) throw (IOException) e.getCause(); Throwable cause = e.getCause();
throw new JsonDataException(e.getCause() + " at " + reader.getPath()); if (cause instanceof IOException) throw (IOException) cause;
throw new JsonDataException(cause + " at " + reader.getPath(), cause);
} }
} }
} }