Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add failure description when a request fails being sent #160

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void answerText(Answer answer, TelegramRequest request) {
try {
execute(answerWithText);
} catch (TelegramApiException e) {
LOGGER.atError().log("Unable to reply to {} with {}", request, answerWithText);
LOGGER.atError().setCause(e).log("Unable to reply to {}", request);
}
}

Expand All @@ -172,7 +172,7 @@ private <T extends BaseRequest<T, R>, R extends BaseResponse> R execute(BaseRequ
return response;
}

throw new TelegramApiException("Telegram couldn't execute the {} request", request.getMethod());
throw new TelegramApiException("Telegram couldn't execute the {} request: {}", request.getMethod(), response.description());
}

private static void deleteTempFiles(Set<Path> pathsToDelete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public TelegramApiException(String message, Throwable cause) {
super(message, cause);
}

/**
* Creates an exception with a parameterized message: each {@code {}}
* will be replaced with the corresponding element in {@code parameters}.
*
* @param message the exception message
* @param parameters the parameters to insert into the message
* @see MessageFormatter#basicArrayFormat(String, Object[])
*/
public TelegramApiException(String message, Object... parameters) {
this(MessageFormatter.basicArrayFormat(message, parameters));
}
Expand Down
Loading