even better error logging
This commit is contained in:
parent
58e5286b3b
commit
a51a07c238
|
@ -79,7 +79,7 @@ public class AsyncHandler implements Runnable {
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
if(current.exceptionhandl == null)
|
if(current.exceptionhandl == null)
|
||||||
throw t;
|
throw t;
|
||||||
System.out.println(String.format("Exception {} handled by {}", t.getClass().getSimpleName(), current.exceptionhandl.getClass().getSimpleName()));
|
System.out.println("Exception " + t.getClass().getSimpleName() + " handled by " + current.exceptionhandl.getClass().getSimpleName());
|
||||||
current.exceptionhandl.call(t);
|
current.exceptionhandl.call(t);
|
||||||
}
|
}
|
||||||
} catch(Throwable t) {
|
} catch(Throwable t) {
|
||||||
|
|
|
@ -150,13 +150,12 @@ public class TelegramAPI implements Runnable {
|
||||||
if (small.length() > 60) {
|
if (small.length() > 60) {
|
||||||
small = small.substring(0, Math.min(60, small.length())) + "...";
|
small = small.substring(0, Math.min(60, small.length())) + "...";
|
||||||
}
|
}
|
||||||
log.log("request: " + request + " content " + small + " -> " + con.getResponseCode() + ", " + con.getResponseMessage());
|
log.log("request: " + request + " content " + small + " -> " + con.getResponseCode() + " " + con.getResponseMessage());
|
||||||
}
|
}
|
||||||
int response = con.getResponseCode();
|
int response = con.getResponseCode();
|
||||||
if (response == 200) {
|
if (response == 200) {
|
||||||
return new JSONObject(readfromIS(con.getInputStream()));
|
return new JSONObject(readfromIS(con.getInputStream()));
|
||||||
} else {
|
} else {
|
||||||
log.log("Request failed - detailed request: " + request + "?" + parameter);
|
|
||||||
String errdesc = "[No description available]";
|
String errdesc = "[No description available]";
|
||||||
try {
|
try {
|
||||||
//try to read error message
|
//try to read error message
|
||||||
|
@ -165,6 +164,8 @@ public class TelegramAPI implements Runnable {
|
||||||
} catch (Throwable ignore) {
|
} catch (Throwable ignore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.log("Request failed error: \"" + errdesc + "\" detailed request: " + request + "?" + parameter);
|
||||||
|
|
||||||
//catch 429 too many error
|
//catch 429 too many error
|
||||||
if (response == 429) {
|
if (response == 429) {
|
||||||
if(trycount < 10) toomany = true;
|
if(trycount < 10) toomany = true;
|
||||||
|
|
Loading…
Reference in New Issue