Skip to content

Commit

Permalink
add error handling case to kitchensink (#1156)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuta Kasai <yuta.kasai@linecorp.com>
  • Loading branch information
tokuhirom and Yang-33 committed Nov 17, 2023
1 parent 160ff63 commit fc1486f
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,22 @@ private void handleTextContent(String replyToken, MessageEvent event, TextMessag
"Hello, I'm cat! Meow~",
null,
null));
case "error" -> {
// demonstrate the case of the invalid request.
// and proper error handling.

// You will get an exception like this:
//
// Caused by: java.lang.RuntimeException: java.util.concurrent.ExecutionException: \
// com.linecorp.bot.messaging.client.MessagingApiClientException: API returns error: \
// code=400 requestUrl=https://api.line.me/v2/bot/message/reply \
// requestId=f3610029-302a-4fc3-8238-d3d6deadbeef error='Invalid reply token' details='null'
try {
this.reply(replyToken + "invalid", new TextMessage("Request error"));
} catch (RuntimeException e) {
log.info("Got an exception: " + e.getMessage(), e);
}
}
default -> {
log.info("Returns echo message {}: {}", replyToken, text);
this.replyText(
Expand Down

0 comments on commit fc1486f

Please sign in to comment.