---
id: "T:cAlgo.API.Error"
kind: "interface"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/Error/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Error (interface)

Encapsulates an error code.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public interface Error
```

## Examples

C#:

```csharp
protected override void OnError(Error error)
{
    Print("Trade error {0}, result: {1}", error.Code, error.TradeResult);
}
```

Python:

```python
def on_error(self, error):
    api.Print(f"Trade error {error.Code}, result: {error.TradeResult}")
```

## Properties

- `ErrorCode Code {get;}` — The encapsulated error code. [details](https://help.ctrader.com/ctrader-algo/references/Trading/Error/Code/index.md)
- `TradeResult TradeResult {get;}` — The result of the trade that produced the error [details](https://help.ctrader.com/ctrader-algo/references/Trading/Error/TradeResult/index.md)

