Source code for pylav.exceptions.node

from __future__ import annotations

import aiohttp

from pylav.exceptions.base import PyLavException


[docs] class NodeException(PyLavException): """Base exception for Node errors"""
[docs] class UnsupportedNodeAPIException(NodeException): """Exception raised when the node version is unsupported"""
[docs] class AbortPlayerRestoreDueUnavailableNodeException(NodeException): """Raised when the player is aborted due to an unavailable node"""
[docs] class WebsocketNotConnectedException(NodeException): """Raised when the node websocket is not connected"""
[docs] class NoNodeAvailableException(NodeException): """Raised when no node is available"""
[docs] class NoNodeWithRequestFunctionalityAvailableException(NodeException): """Raised when no node with request functionality is available""" def __init__(self, message: str, feature: str, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.message = message self.feature = feature
[docs] class NodeHasNoFiltersException(NodeException): """Raised when a node has no filters""" def __init__(self, message: str, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.message = message
[docs] class ManagedLavalinkNodeException(NodeException): """Base Exception for Managed Lavalink Node Exceptions"""
[docs] class NodeUnhealthyException(ManagedLavalinkNodeException): """Exception Raised when the node health checks fail"""
[docs] class InvalidArchitectureException(ManagedLavalinkNodeException): """Exception thrown when the Managed Lavalink node is started on an invalid arch"""
[docs] class ManagedLavalinkAlreadyRunningException(ManagedLavalinkNodeException): """Exception thrown when a managed Lavalink node is already running"""
[docs] class PortAlreadyInUseException(ManagedLavalinkNodeException): """Exception thrown when the port is already in use"""
[docs] class ManagedLinkStartAbortedUseExternal(ManagedLavalinkNodeException): """Exception thrown when the managed lavalink node is started but aborted"""
[docs] class ManagedLavalinkStartFailureException(ManagedLavalinkNodeException): """Exception thrown when a managed Lavalink node fails to start"""
[docs] class ManagedLavalinkPreviouslyShutdownException(ManagedLavalinkNodeException): """Exception thrown when a managed Lavalink node already has been shutdown"""
[docs] class EarlyExitException(ManagedLavalinkNodeException): """some placeholder text I cannot be bothered to add a meaning message atm"""
[docs] class UnsupportedJavaException(ManagedLavalinkNodeException): """Exception thrown when a managed Lavalink node doesn't have a supported Java"""
[docs] class UnexpectedJavaResponseException(ManagedLavalinkNodeException): """Exception thrown when Java returns an unexpected response"""
[docs] class NoProcessFoundException(ManagedLavalinkNodeException): """Exception thrown when the managed node process is not found"""
[docs] class IncorrectProcessFoundException(ManagedLavalinkNodeException): """Exception thrown when the managed node process is incorrect"""
[docs] class TooManyProcessFoundException(ManagedLavalinkNodeException): """Exception thrown when zombie processes are suspected"""
[docs] class LavalinkDownloadFailedException(ManagedLavalinkNodeException, RuntimeError): """Downloading the Lavalink jar failed. Attributes ---------- response : aiohttp.ClientResponse The response from the server to the failed GET request. should_retry : bool Whether the lib should retry downloading the jar. """ def __init__(self, *args, response: aiohttp.ClientResponse, should_retry: bool = False) -> None: super().__init__(*args) self.response = response self.should_retry = should_retry def __repr__(self) -> str: str_args = [*map(str, self.args), self._response_repr()] return f"LavalinkDownloadFailed({', '.join(str_args)}" def __str__(self) -> str: return f"{super().__str__()} {self._response_repr()}" def _response_repr(self) -> str: return f"[{self.response.status} {self.response.reason}]"