---
id: "P:cAlgo.API.Error.Code"
kind: "property"
type: "T:cAlgo.API.Error"
url: "https://help.ctrader.com/ctrader-algo/references/Trading/Error/Code/"
---

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

# Error.Code

Member of [Error](https://help.ctrader.com/ctrader-algo/references/Trading/Error/index.md).

## Code

The encapsulated error code.

Environments: Desktop supported · CLI supported · Cloud supported.

C#:

```csharp
ErrorCode Code {get;}
```

Python:

```python
error.Code: ErrorCode
```

### Returns

`ErrorCode` — 

### Examples

C#:

```csharp
protected override void OnError(Error error)
{
    if (error.Code == ErrorCode.BadVolume)
    {
        Print("Invalid volume, stopping the cBot");
        Stop();
    }
}
```

Python:

```python
def on_error(self, error):
    if error.Code == ErrorCode.BadVolume:
        api.Print("Invalid volume, stopping the cBot")
        api.Stop()
```

