pinterest-java
pinterest-java copied to clipboard
Handle Errors Better - Save response code as field PinterestException
Handle errors like this:
Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 27 path $.data.attribution
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:221)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217)
at com.google.gson.Gson.fromJson(Gson.java:861)
at com.google.gson.Gson.fromJson(Gson.java:826)
at com.google.gson.Gson.fromJson(Gson.java:775)
at com.google.gson.Gson.fromJson(Gson.java:747)
at com.chrisdempewolf.pinterest.methods.pin.PinMethodDelegate.getPin(PinMethodDelegate.java:40)
at com.chrisdempewolf.pinterest.Pinterest.getPin(Pinterest.java:32)
at com.datarank.krunch.crawlers.datasources.urlhandlers.pinterest.helper.PinterestCrawlingUtils$PinIdToPinResponseFunction.valueOf(PinterestCrawlingUtils.java:64)
at com.datarank.krunch.crawlers.datasources.urlhandlers.pinterest.helper.PinterestCrawlingUtils$PinIdToPinResponseFunction.valueOf(PinterestCrawlingUtils.java:53)
at com.gs.collections.impl.utility.internal.InternalArrayIterate.collect(InternalArrayIterate.java:450)
at com.gs.collections.impl.list.immutable.ImmutableArrayList.collect(ImmutableArrayList.java:228)
at com.datarank.krunch.crawlers.datasources.urlhandlers.pinterest.helper.PinterestCrawlingUtils.parsePinterestCommentEntities(PinterestCrawlingUtils.java:105)
at com.datarank.krunch.crawlers.datasources.urlhandlers.pinterest.helper.PinterestCrawlingUtils.parsePinterestCommentEntitiesWithRepinFollowers(PinterestCrawlingUtils.java:117)
at com.datarank.krunch.datasources.services.PinterestBoardCsvWriter.findPinsForPinIds(PinterestBoardCsvWriter.java:122)
at com.datarank.krunch.datasources.services.PinterestBoardCsvWriter.runWithCmdLineArgs(PinterestBoardCsvWriter.java:94)
at com.datarank.krunch.datasources.services.PinterestBoardCsvWriter.main(PinterestBoardCsvWriter.java:82)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 27 path $.data.attribution
at com.google.gson.stream.JsonReader.nextString(JsonReader.java:838)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:422)
at com.google.gson.internal.bind.TypeAdapters$16.read(TypeAdapters.java:410)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:217)
... 22 more