-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: errors not propagating in some situations
BT-49
- Loading branch information
Showing
5 changed files
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import disnake | ||
import logoo | ||
from disnake import Embed | ||
from logoo import Logger | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .error_wrapper import wrap_with_error_handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import functools | ||
from typing import Callable | ||
|
||
from suggestions.interaction_handler import InteractionHandler | ||
|
||
|
||
def wrap_with_error_handler(): | ||
def decorator(func: Callable): | ||
@functools.wraps(func) | ||
async def wrapper(*args, **kwargs): | ||
try: | ||
return await func(*args, **kwargs) | ||
except Exception as e: | ||
inter = ( | ||
args[1].interaction | ||
if isinstance(args[1], InteractionHandler) | ||
else args[1] | ||
) | ||
await args[0].bot.on_slash_command_error(inter, e) | ||
|
||
return wrapper | ||
|
||
return decorator |