Skip to content

Commit 5d5730e

Browse files
committed
Fix: discord bot freezing when encountering error in searching
1 parent b89dccc commit 5d5730e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2323

2424
### Fixed
2525

26-
- Fixed discord bot logging format to diagnose errors
26+
- Fix discord bot logging format to diagnose errors
27+
- Fix discord bot freezing when encountering error in searching
2728

2829
## [0.8.1] - 2021-12-13
2930

novelsave/client/bots/discord/endpoints/search.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ def search(self, word: str):
6565
logger.debug(f"'{gateway.name}' does not support search.")
6666
return
6767

68-
novels = gateway.search(word)
68+
try:
69+
novels = gateway.search(word)
70+
except Exception as e:
71+
logger.exception(e)
72+
self.session.send_sync(
73+
mfmt.error(
74+
f"Encountered error while searching in {gateway.name}: {type(e).__name__}"
75+
)
76+
)
77+
continue
78+
6979
logger.debug(f"Found {len(novels)} novels in '{gateway.name}'.")
7080
for novel in novels:
7181
self.results.setdefault(novel.title, []).append(novel)

0 commit comments

Comments
 (0)