Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 72fc313

Browse files
committed
improved error handling
1 parent 39b32ce commit 72fc313

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/kohsuke/github/Requester.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.regex.Pattern;
5353
import java.util.zip.GZIPInputStream;
5454

55+
import com.fasterxml.jackson.databind.JsonMappingException;
5556
import org.apache.commons.io.IOUtils;
5657

5758
import javax.net.ssl.HttpsURLConnection;
@@ -396,7 +397,11 @@ private <T> T parse(HttpURLConnection uc, Class<T> type, T instance) throws IOEx
396397
r = new InputStreamReader(wrapStream(uc, uc.getInputStream()), "UTF-8");
397398
String data = IOUtils.toString(r);
398399
if (type!=null)
399-
return MAPPER.readValue(data,type);
400+
try {
401+
return MAPPER.readValue(data,type);
402+
} catch (JsonMappingException e) {
403+
throw (IOException)new IOException("Failed to deserialize "+data).initCause(e);
404+
}
400405
if (instance!=null)
401406
return MAPPER.readerForUpdating(instance).<T>readValue(data);
402407
return null;

0 commit comments

Comments
 (0)