Completed
Push — main ( 569940...9b1556 )
by
unknown
26s queued 12s
created

pincer.middleware.error.export()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 0
1
# Copyright Pincer 2021-Present
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
"""
5
non-subscription event sent when there is an error,
6
including command responses
7
"""
8
from __future__ import annotations
9
10
from typing import TYPE_CHECKING
11
12
from ..objects.events.error import DiscordError
13
from ..utils.conversion import construct_client_dict
14
from ..utils.types import Coro
15
16
if TYPE_CHECKING:
17
    from typing import List, Tuple
18
    from ..core.dispatch import GatewayDispatch
19
20
21
def error_middleware(
22
    self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
23
    payload: GatewayDispatch
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
24
) -> Tuple[str, List[DiscordError]]:
25
    """|coro|
26
27
    Middleware for ``on_error`` event.
28
29
    Parameters
30
    ----------
31
    payload : :class:`~pincer.core.dispatch.GatewayDispatch`
32
        The data received from the ready event.
33
34
    Returns
35
    -------
36
    Tuple[:class:`str`, List[:class:`~pincer.objects.events.error.DiscordError`]]
37
        ``"on_error"`` and a ``DiscordError``
38
    """  # noqa: E501
39
40
    return "on_error", [
41
        DiscordError.from_dict(construct_client_dict(self, payload.data))
42
    ]
43
44
45
def export() -> Coro:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
46
    return error_middleware
47