Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

feat: Convert client.on_error into a proper event #573

Merged
merged 3 commits into from
Jul 31, 2022
Merged

Conversation

silasary
Copy link
Collaborator

@silasary silasary commented Jul 28, 2022

  • Non-breaking code change
  • Breaking code change
  • Documentation change/addition
  • Tests change

Description

This makes the error handler a dispatchable event, allowing Extensions listen to all events (prereq for #403)

Changes

Adds new Internal Event naff.api.events.internal.Error
Changes all calls to client.on_error to dispatch that event instead
Adds a non-breaking listener client._on_event that calls the existing method.
Also fixes implausible bug when on_command_error is called without a valid bot token.

Checklist

  • I've formatted my code with Black
  • I've ensured my code works on Python 3.10.x
  • I've tested my code

Comment on lines 171 to 175
source: str
error: Exception
args: tuple[Any] = field(factory=tuple)
kwargs: dict[str, Any] = field(factory=dict)
ctx: Optional["Context"] = field(default=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you docstring these attributes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure how to document args and kwargs.

@LordOfPolls LordOfPolls added Improvement Something that is already implemented but can be done better New Feature::Library A new feature for the library labels Jul 29, 2022
@silasary silasary merged commit 547c4f6 into dev Jul 31, 2022
@silasary silasary deleted the error_listener branch July 31, 2022 06:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Improvement Something that is already implemented but can be done better New Feature::Library A new feature for the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants