Module server.exceptions

Common exception definitions

Classes

class AuthenticationError (message, method, *args, **kwargs)

The operation failed to authenticate.

Expand source code
class AuthenticationError(Exception):
    """
    The operation failed to authenticate.
    """

    def __init__(self, message, method, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.message = message
        self.method = method

Ancestors

  • builtins.Exception
  • builtins.BaseException
class BanError (ban_expiry, ban_reason, *args, **kwargs)

Signals that an operation could not be completed because the user is banned.

Expand source code
class BanError(Exception):
    """
    Signals that an operation could not be completed because the user is banned.
    """

    def __init__(self, ban_expiry, ban_reason, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ban_expiry = ban_expiry
        self.ban_reason = ban_reason

    def message(self):
        return (
            f"You are banned from FAF {self._ban_duration_text()}. <br>"
            f"Reason: <br>{self.ban_reason}<br><br>"
            "<i>If you would like to appeal this ban, please send an email to: "
            "moderation@faforever.com</i>"
        )

    def _ban_duration_text(self):
        ban_duration = self.ban_expiry - datetime.utcnow()
        if ban_duration.days > 365 * 100:
            return "forever"
        humanized_ban_duration = humanize.precisedelta(
            ban_duration,
            minimum_unit="hours"
        )
        return f"for {humanized_ban_duration}"

Ancestors

  • builtins.Exception
  • builtins.BaseException

Methods

def message(self)
class ClientError (message, recoverable=True, *args, **kwargs)

Represents a protocol violation by the client.

If recoverable is False, it is expected that the connection be terminated immediately.

Expand source code
class ClientError(Exception):
    """
    Represents a protocol violation by the client.

    If recoverable is False, it is expected that the connection be terminated
    immediately.
    """

    def __init__(self, message, recoverable=True, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.message = message
        self.recoverable = recoverable

Ancestors

  • builtins.Exception
  • builtins.BaseException
class DisabledError (*args, **kwargs)

The operation is disabled due to an impending server shutdown.

Expand source code
class DisabledError(Exception):
    """
    The operation is disabled due to an impending server shutdown.
    """

Ancestors

  • builtins.Exception
  • builtins.BaseException