Skip to content

Commit 36fea34

Browse files
authored
revert: #1945 (#2103)
* Revert "feat!: Client.on_error() improvement with new parameter (#1945)" This reverts commit 7f192fe. * chore: remove changelog entry of reverted pr
1 parent d8377f0 commit 36fea34

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ These changes are available on the `master` branch, but have not yet been releas
8282
([#2063](https://github.com/Pycord-Development/pycord/pull/2063))
8383
- `default_avatar` behavior changes depending on the user's username migration status.
8484
([#2087](https://github.com/Pycord-Development/pycord/pull/2087))
85-
- `Client.on_error()` now has an `exception` parameter for easier error handling.
86-
([#1945](https://github.com/Pycord-Development/pycord/pull/1945))
8785
- Typehinted `command_prefix` and `help_command` arguments properly.
8886
([#2099](https://github.com/Pycord-Development/pycord/pull/2099))
8987

discord/client.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,9 @@ async def _run_event(
399399
await coro(*args, **kwargs)
400400
except asyncio.CancelledError:
401401
pass
402-
except Exception as exc:
402+
except Exception:
403403
try:
404-
await self.on_error(event_name, exc, *args, **kwargs)
404+
await self.on_error(event_name, *args, **kwargs)
405405
except asyncio.CancelledError:
406406
pass
407407

@@ -481,9 +481,7 @@ def dispatch(self, event: str, *args: Any, **kwargs: Any) -> None:
481481
for coro in once_listeners:
482482
self._event_handlers[method].remove(coro)
483483

484-
async def on_error(
485-
self, event_method: str, exception: Exception, *args: Any, **kwargs: Any
486-
) -> None:
484+
async def on_error(self, event_method: str, *args: Any, **kwargs: Any) -> None:
487485
"""|coro|
488486
489487
The default error handler provided by the client.

docs/api/events.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,17 @@ Channels
252252

253253
Connection
254254
----------
255-
.. function:: on_error(event, exception, *args, **kwargs)
255+
.. function:: on_error(event, *args, **kwargs)
256256

257257
Usually when an event raises an uncaught exception, a traceback is
258258
printed to stderr and the exception is ignored. If you want to
259259
change this behaviour and handle the exception for whatever reason
260260
yourself, this event can be overridden. Which, when done, will
261261
suppress the default action of printing the traceback.
262262

263+
The information of the exception raised and the exception itself can
264+
be retrieved with a standard call to :func:`sys.exc_info`.
265+
263266
If you want exception to propagate out of the :class:`Client` class
264267
you can define an ``on_error`` handler consisting of a single empty
265268
:ref:`raise statement <py:raise>`. Exceptions raised by ``on_error`` will not be
@@ -276,9 +279,6 @@ Connection
276279
:param event: The name of the event that raised the exception.
277280
:type event: :class:`str`
278281

279-
:param exception: The exception raised by the event.
280-
:type event: :class:`Exception`
281-
282282
:param args: The positional arguments for the event that raised the
283283
exception.
284284
:param kwargs: The keyword arguments for the event that raised the

0 commit comments

Comments
 (0)