Cog-Creators / Cog-Creators/Red-DiscordBot

Commands should raise exceptions for errors rather than handle it in-line

Open
#3,600 0 comments 0 reactions 0 assignees View on GitHub
Category: Core - API - Commands Package Category: Core - Other Internals Status: Accepted Type: Feature
Dominant language
Python
Stars
5.7k
Forks
2.5k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

# Feature request

#### Select the type of feature you are requesting:

- [ ] Cog
- [ ] Command
- [x] API functionality

#### Describe your requested feature

While it should be easy to add few automatic error handlers, rewriting all commands to raise exceptions for any errors is gonna take some time.

If someone would PR such error handlers, we could then gradually make PRs that would make commands raise exceptions instead of handling errors in-line as it's time-consuming to do all of this alone (and it might be too big a change for one PR too).

From original issue (#3206):
> To allow 3rd party extensions to accurately detect when a command ran but was unsuccessful.
>
> Right now, we usually handle command errors in-line.
>
> Ideally, we'd be raising and handling command errors so that events such as `on_command_completion` and `on_command_error` accurately describe if a command finished normally.
>
> To make this easier, we could add a few automatic error handlers.
>
> The most generic of these, but also likely the most useful would be:
> `CommandErrorSend(location, content)`
>
> Which internally would be handled as just using `bot.send_filtered`, but would signal that the command was unsuccessful to listener users.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.