Exceptions¶
mt5cli.exceptions ¶
Normalized exception types for MT5 and mt5cli operations.
__all__
module-attribute
¶
__all__ = [
"Mt5CliError",
"Mt5ConnectionError",
"Mt5OperationError",
"Mt5SchemaError",
"call_with_normalized_errors",
"is_recoverable_mt5_error",
"normalize_mt5_exception",
]
Mt5CliError ¶
Bases: Exception
Base exception for mt5cli public API errors.
Mt5ConnectionError ¶
Bases: Mt5CliError
Raised when MT5 initialization, login, or shutdown fails.
Mt5OperationError ¶
Bases: Mt5CliError
Raised when an MT5 data or trading operation fails.
Mt5SchemaError ¶
Bases: Mt5CliError
Raised when a DataFrame does not match an expected dataset schema.
call_with_normalized_errors ¶
Run fn and map recoverable MT5 errors to mt5cli types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[[], T]
|
Callable performing MT5 work. |
required |
Returns:
| Type | Description |
|---|---|
T
|
Value returned by |
Source code in mt5cli/exceptions.py
is_recoverable_mt5_error ¶
Return whether an exception is a transient MT5 failure worth retrying.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc
|
BaseException
|
Exception raised by MT5 or pdmt5. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for |
Source code in mt5cli/exceptions.py
normalize_mt5_exception ¶
normalize_mt5_exception(exc: BaseException) -> Mt5CliError
Map pdmt5/MT5 exceptions to stable mt5cli exception types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc
|
BaseException
|
Original exception from MT5 or pdmt5. |
required |
Returns:
| Type | Description |
|---|---|
Mt5CliError
|
|
Mt5CliError
|
trading failures, or the original exception when it is not recognized. |