diff --git a/mt5bridge_ccxt/exceptions.py b/mt5bridge_ccxt/exceptions.py new file mode 100644 index 0000000..4dfaa60 --- /dev/null +++ b/mt5bridge_ccxt/exceptions.py @@ -0,0 +1,58 @@ +"""Custom exceptions for mt5bridge-ccxt. + +All exceptions inherit from Mt5BridgeError so callers can catch the +base class for any wrapper-related failure. +""" + +from ccxt.base.errors import ( + ExchangeError, + AuthenticationError, + NetworkError, + ExchangeNotAvailable, + InvalidOrder, + OrderNotFound, + BadSymbol, + BadRequest, + ArgumentsRequired, +) + + +class Mt5BridgeError(ExchangeError): + """Base exception for all MT5Bridge-related errors.""" + + +class Mt5BridgeConnectionError(NetworkError): + """Connection to MT5Bridge failed (host unreachable, timeout, etc.).""" + + +class Mt5BridgeAuthError(AuthenticationError): + """Authentication failed (HTTP 401). Check your API key.""" + + +class Mt5BridgeNotConnectedError(ExchangeNotAvailable): + """MT5 client is not connected to the broker (HTTP 503).""" + + +class Mt5BridgeInvalidRequestError(BadRequest): + """Invalid request parameters (HTTP 400).""" + + +class Mt5BridgeTimeoutError(NetworkError): + """Request to MT5Bridge timed out.""" + + +# Re-export ccxt exceptions for convenience +__all__ = [ + "Mt5BridgeError", + "Mt5BridgeConnectionError", + "Mt5BridgeAuthError", + "Mt5BridgeNotConnectedError", + "Mt5BridgeInvalidRequestError", + "Mt5BridgeTimeoutError", + "InvalidOrder", + "OrderNotFound", + "BadSymbol", + "BadRequest", + "ArgumentsRequired", + "ExchangeError", +]