Edit on GitHub

tickets_plus.ext.exceptions

General exceptions that we can use in the application.

This module contains general exceptions that we can use in the application. These exceptions are used to handle errors in a more elegant way. Most of these exceptions are a subclass of discord.app_commands.AppCommandError.

Typical usage example:
from tickets_plus.ext import exceptions
try:
    ...
except exceptions.ReferenceNotFound:
    ...
 1"""General exceptions that we can use in the application.
 2
 3This module contains general exceptions that we can use in the application.
 4These exceptions are used to handle errors in a more elegant way. Most of these
 5exceptions are a subclass of `discord.app_commands.AppCommandError`.
 6
 7Typical usage example:
 8    ```py
 9    from tickets_plus.ext import exceptions
10    try:
11        ...
12    except exceptions.ReferenceNotFound:
13        ...
14    ```
15"""
16# License: EPL-2.0
17# SPDX-License-Identifier: EPL-2.0
18# Copyright (c) 2021-present The Tickets+ Contributors
19# This Source Code may also be made available under the following
20# Secondary Licenses when the conditions for such availability set forth
21# in the Eclipse Public License, v. 2.0 are satisfied: GPL-3.0-only OR
22# If later approved by the Initial Contributor, GPL-3.0-or-later.
23
24from discord import app_commands
25
26
27class TicketsPlusCommandError(app_commands.AppCommandError):
28    """Base class for Tickets+ exceptions.
29
30    This is the base class for all Tickets+ exceptions.
31    Avoid using this exception, use a subclass of this exception instead.
32    If you are using this exception, please consider creating a subclass of
33    for your use case.
34    This is a subclass of `discord.app_commands.AppCommandError` to use
35    the library's app command handling functions.
36    """
37
38
39class TicketsCheckFailure(app_commands.CheckFailure):
40    """Command failed ticket checks.
41
42    An app command failed the ticket checks.
43    This is usually used when a user tries to execute a command
44     not allowed in the current ticket state.
45    """
46
47
48class ReferenceNotFound(TicketsPlusCommandError):
49    """Command executed with invalid reference.
50
51    A previously valid reference no longer resolves successfully.
52    Mostly caused by manual deletion of the referenced object,
53    by the user.
54    """
55
56
57class UsageError(TicketsPlusCommandError):
58    """Command executed with invalid usage.
59
60    An app command was executed with invalid usage.
61    A broad Tickets+ exception that is used when a command is executed
62    in an invalid way.
63    """
64
65
66class InvalidLocation(UsageError):
67    """Command executed in an invalid location.
68
69    An app command was executed in an invalid location.
70    This is usually used when a command is executed in a DM channel,
71    or in general, a channel that is invalid for the command.
72    """
73
74
75class InvalidParameters(UsageError):
76    """Command executed with invalid parameters.
77
78    An app command was executed with invalid parameters.
79    This is usually used when a user provides invalid parameters to a command.
80    """
class TicketsPlusCommandError(discord.app_commands.errors.AppCommandError):
28class TicketsPlusCommandError(app_commands.AppCommandError):
29    """Base class for Tickets+ exceptions.
30
31    This is the base class for all Tickets+ exceptions.
32    Avoid using this exception, use a subclass of this exception instead.
33    If you are using this exception, please consider creating a subclass of
34    for your use case.
35    This is a subclass of `discord.app_commands.AppCommandError` to use
36    the library's app command handling functions.
37    """

Base class for Tickets+ exceptions.

This is the base class for all Tickets+ exceptions. Avoid using this exception, use a subclass of this exception instead. If you are using this exception, please consider creating a subclass of for your use case. This is a subclass of discord.app_commands.AppCommandError to use the library's app command handling functions.

class TicketsCheckFailure(discord.app_commands.errors.CheckFailure):
40class TicketsCheckFailure(app_commands.CheckFailure):
41    """Command failed ticket checks.
42
43    An app command failed the ticket checks.
44    This is usually used when a user tries to execute a command
45     not allowed in the current ticket state.
46    """

Command failed ticket checks.

An app command failed the ticket checks. This is usually used when a user tries to execute a command not allowed in the current ticket state.

class ReferenceNotFound(TicketsPlusCommandError):
49class ReferenceNotFound(TicketsPlusCommandError):
50    """Command executed with invalid reference.
51
52    A previously valid reference no longer resolves successfully.
53    Mostly caused by manual deletion of the referenced object,
54    by the user.
55    """

Command executed with invalid reference.

A previously valid reference no longer resolves successfully. Mostly caused by manual deletion of the referenced object, by the user.

class UsageError(TicketsPlusCommandError):
58class UsageError(TicketsPlusCommandError):
59    """Command executed with invalid usage.
60
61    An app command was executed with invalid usage.
62    A broad Tickets+ exception that is used when a command is executed
63    in an invalid way.
64    """

Command executed with invalid usage.

An app command was executed with invalid usage. A broad Tickets+ exception that is used when a command is executed in an invalid way.

class InvalidLocation(UsageError):
67class InvalidLocation(UsageError):
68    """Command executed in an invalid location.
69
70    An app command was executed in an invalid location.
71    This is usually used when a command is executed in a DM channel,
72    or in general, a channel that is invalid for the command.
73    """

Command executed in an invalid location.

An app command was executed in an invalid location. This is usually used when a command is executed in a DM channel, or in general, a channel that is invalid for the command.

class InvalidParameters(UsageError):
76class InvalidParameters(UsageError):
77    """Command executed with invalid parameters.
78
79    An app command was executed with invalid parameters.
80    This is usually used when a user provides invalid parameters to a command.
81    """

Command executed with invalid parameters.

An app command was executed with invalid parameters. This is usually used when a user provides invalid parameters to a command.