From 00085adfd6740700669a50b08dbecbce3d0bfdb2 Mon Sep 17 00:00:00 2001 From: Slavomir Hustaty Date: Mon, 19 Apr 2021 10:09:36 +0200 Subject: [PATCH] Update TelegramApiRequestException.java https://github.com/rubenlagus/TelegramBots/issues/892 https://github.com/rubenlagus/TelegramBots/pull/893 --- .../TelegramApiRequestException.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java index 1dd7bcf7..53280d10 100644 --- a/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java +++ b/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/exceptions/TelegramApiRequestException.java @@ -84,8 +84,13 @@ public class TelegramApiRequestException extends TelegramApiException { return parameters; } + /** + * More detailed error description. + * + * @return assembled response code and reason + */ @Override - public String toString() { + public String getMessage() { if (apiResponse == null) { return super.toString(); } else if (errorCode == null) { @@ -94,4 +99,15 @@ public class TelegramApiRequestException extends TelegramApiException { return super.toString() + ": [" + errorCode + "] " + apiResponse; } } + + /** + * Just left as backward compatibility if anybody used this in version 5.1.1 or older. + * + * @return the getMessage string + */ + @Override + public String toString() { + return getMessage(); + } + }