fixed error reading

This commit is contained in:
mrbesen 2019-04-11 01:41:15 +02:00
parent 01866b6a32
commit 9a8de527a1
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 3 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import java.util.Scanner;
import javax.net.ssl.HttpsURLConnection;
import de.mrbesen.telegram.commands.JSONCommandHandler;
import org.json.JSONArray;
import org.json.JSONObject;
@ -126,8 +127,8 @@ public class TelegramAPI implements Runnable {
} else {
String errdesc = "[No description available]";
try {
//try to read anyway to get error message
JSONObject returned = new JSONObject(readfromIS(con.getInputStream()));
//try to read error message
JSONObject returned = new JSONObject(readfromIS(con.getErrorStream()));
errdesc = returned.getString("description");
} catch(Throwable ignore) { }
throw new APIError(parameter, request, con.getResponseCode(), null, errdesc);