Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit d53f84c

Browse files
committed
1. Global exceptions
1 parent d4a8f3e commit d53f84c

File tree

8 files changed

+186
-121
lines changed

8 files changed

+186
-121
lines changed

.idea/libraries/Maven__com_github_rubenlagus_TelegramBots_v2_0_1.xml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.idea/workspace.xml

Lines changed: 154 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/telegram/updateshandlers/ChannelHandlers.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ public class ChannelHandlers extends TelegramLongPollingBot {
3636

3737
@Override
3838
public void onUpdateReceived(Update update) {
39-
Message message = update.getMessage();
40-
if (message != null && message.hasText()) {
41-
try {
42-
handleIncomingMessage(message);
43-
} catch (InvalidObjectException e) {
44-
BotLogger.severe(LOGTAG, e);
39+
try {
40+
Message message = update.getMessage();
41+
if (message != null && message.hasText()) {
42+
try {
43+
handleIncomingMessage(message);
44+
} catch (InvalidObjectException e) {
45+
BotLogger.severe(LOGTAG, e);
46+
}
4547
}
48+
} catch (Exception e) {
49+
BotLogger.error(LOGTAG, e);
4650
}
4751
}
4852

src/main/java/org/telegram/updateshandlers/DirectionsHandlers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String getBotToken() {
4949
public void onUpdateReceived(Update update) {
5050
try {
5151
handleDirections(update);
52-
} catch (InvalidObjectException e) {
52+
} catch (Exception e) {
5353
BotLogger.error(LOGTAG, e);
5454
}
5555
}

src/main/java/org/telegram/updateshandlers/FilesHandlers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public String getBotToken() {
4646
public void onUpdateReceived(Update update) {
4747
try {
4848
handleFileUpdate(update);
49-
} catch (InvalidObjectException e) {
49+
} catch (Exception e) {
5050
BotLogger.error(LOGTAG, e);
5151
}
5252
}

src/main/java/org/telegram/updateshandlers/RaeHandlers.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ public String getBotToken() {
4343

4444
@Override
4545
public void onUpdateReceived(Update update) {
46-
if (update.hasInlineQuery()) {
47-
handleIncomingInlineQuery(update.getInlineQuery());
48-
} else if (update.hasMessage() && update.getMessage().isUserMessage()) {
49-
try {
50-
sendMessage(getHelpMessage(update.getMessage()));
51-
} catch (TelegramApiException e) {
52-
e.printStackTrace();
46+
try {
47+
if (update.hasInlineQuery()) {
48+
handleIncomingInlineQuery(update.getInlineQuery());
49+
} else if (update.hasMessage() && update.getMessage().isUserMessage()) {
50+
try {
51+
sendMessage(getHelpMessage(update.getMessage()));
52+
} catch (TelegramApiException e) {
53+
BotLogger.error(LOGTAG, e);
54+
}
5355
}
56+
} catch (Exception e) {
57+
BotLogger.error(LOGTAG, e);
5458
}
5559
}
5660

src/main/java/org/telegram/updateshandlers/TransifexHandlers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public String getBotToken() {
3333
public void onUpdateReceived(Update update) {
3434
try {
3535
sendTransifexFile(update);
36-
} catch (InvalidObjectException e) {
36+
} catch (Exception e) {
3737
BotLogger.error(LOGTAG, e);
3838
}
3939
}

src/main/java/org/telegram/updateshandlers/WeatherHandlers.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ public String getBotToken() {
6060

6161
@Override
6262
public void onUpdateReceived(Update update) {
63-
if (update.hasMessage()) {
64-
Message message = update.getMessage();
65-
if (message.hasText() || message.hasLocation()) {
66-
handleIncomingMessage(message);
63+
try {
64+
if (update.hasMessage()) {
65+
Message message = update.getMessage();
66+
if (message.hasText() || message.hasLocation()) {
67+
handleIncomingMessage(message);
68+
}
6769
}
70+
} catch (Exception e) {
71+
BotLogger.error(LOGTAG, e);
6872
}
6973
}
7074

0 commit comments

Comments
 (0)