even better error logging

This commit is contained in:
mrbesen 2020-09-17 15:05:54 +02:00
parent 58e5286b3b
commit a51a07c238
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
2 changed files with 4 additions and 3 deletions

View File

@ -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) {

View File

@ -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;