Skip to content

Commit 5de958b

Browse files
committed
fix(prefix_manager): improve error handling for prefix caching
- Added exception handling around the caching process in the PrefixManager class to log warnings when caching fails. - This change enhances the robustness of prefix management by ensuring that errors during caching are properly logged, aiding in troubleshooting.
1 parent bd2c943 commit 5de958b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/tux/core/prefix_manager.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,15 @@ async def _load_guild_prefix(self, guild_id: int) -> str:
170170

171171
prefix = guild_config.prefix
172172
self._prefix_cache[guild_id] = prefix
173-
backend = get_cache_backend(self.bot)
174-
await backend.set(f"prefix:{guild_id}", prefix, ttl_sec=None)
173+
try:
174+
backend = get_cache_backend(self.bot)
175+
await backend.set(f"prefix:{guild_id}", prefix, ttl_sec=None)
176+
except Exception as e:
177+
logger.warning(
178+
"Failed to cache prefix for guild {}: {}",
179+
guild_id,
180+
type(e).__name__,
181+
)
175182

176183
except Exception as e:
177184
logger.warning(

0 commit comments

Comments
 (0)