---
id: "T:cAlgo.API.LocalStorageException"
kind: "class"
namespace: "cAlgo.API"
url: "https://help.ctrader.com/ctrader-algo/references/Localstorage/LocalStorageException/"
---

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

# LocalStorageException (class)

Represents errors that occur during local storage operations. This exception will be passed to cBot / indicator OnException method.

Environments: Desktop supported · CLI supported · Cloud supported.

## Definition

```csharp
public sealed class LocalStorageException : Exception
```

## Examples

C#:

```csharp
protected override void OnStart()
{
    LocalStorage.SetString("Last Start", Server.Time.ToString("O"));
}

protected override void OnException(Exception exception)
{
    if (exception is LocalStorageException)
        Print("Local storage error: {0}", exception.Message);
}
```

Python:

```python
def on_start(self):
    api.LocalStorage.SetString("Last Start", api.Server.Time.ToString("O"))

def on_exception(self, exception):
    if isinstance(exception, LocalStorageException):
        api.Print(f"Local storage error: {exception.Message}")
```

