> ## Documentation Index
> Fetch the complete documentation index at: https://docs.liv.tv/llms.txt
> Use this file to discover all available pages before exploring further.

# LckError

> Error codes that explain why LCK operations fail, returned in LckResult for debugging and error handling.

## What Problem Does This Solve?

When an LCK operation fails (starting recording, capturing a photo, changing settings), you need to know *why* it failed. Was it a permission issue? Storage full? Already recording? Wrong platform?

`LckError` provides specific error codes so you can handle failures appropriately—show the right error message, retry the operation, or disable features.

## When to Use This

You'll check `LckError` whenever an `LckResult` indicates failure:

```csharp theme={null}
var result = lckService.StartRecording();
if (!result.IsOk)
{
    // result.Error contains the LckError enum value
    switch (result.Error)
    {
        case LckError.NotEnoughStorageSpace:
            ShowError("Not enough storage space to record");
            break;
        case LckError.MicrophonePermissionDenied:
            ShowError("Microphone permission required");
            break;
        default:
            ShowError($"Recording failed: {result.Message}");
            break;
    }
}
```

***

## Common Error Scenarios

### Storage Issues

```csharp theme={null}
if (result.Error == LckError.NotEnoughStorageSpace)
{
    // Prompt user to free up space
    long bytesNeeded = GetEstimatedRecordingSize();
    ShowStorageWarning($"Need {bytesNeeded / 1_000_000} MB free");
}
```

### Permission Errors

```csharp theme={null}
if (result.Error == LckError.MicrophonePermissionDenied)
{
    // Request permission or guide user to settings
    RequestMicrophonePermission();
}
```

### State Errors

```csharp theme={null}
if (result.Error == LckError.RecordingAlreadyStarted)
{
    // User already recording, show status instead
    Debug.Log("Recording already in progress");
    return;
}

if (result.Error == LckError.NotCurrentlyRecording)
{
    // Tried to stop when not recording
    Debug.LogWarning("No active recording to stop");
}
```

### Platform/Compatibility

```csharp theme={null}
if (result.Error == LckError.UnsupportedGraphicsApi)
{
    ShowError("Graphics API not supported. Try switching to Vulkan or DirectX11.");
}

if (result.Error == LckError.UnsupportedPlatform)
{
    ShowError("LCK is not supported on this platform");
}
```

***

## Error Categories

### **Initialization & Setup Errors**

| Error                    | When It Happens                      | How to Fix                            |
| ------------------------ | ------------------------------------ | ------------------------------------- |
| `ServiceNotCreated`      | Calling LCK before initialization    | Call `LckCore.Initialize()` first     |
| `ServiceDisposed`        | Using LCK after disposal             | Don't use after calling `Dispose()`   |
| `InvalidDescriptor`      | Bad configuration in `LckDescriptor` | Check camera/quality settings         |
| `UnsupportedGraphicsApi` | Graphics API not supported           | Switch to DirectX11, Vulkan, or Metal |
| `UnsupportedPlatform`    | Platform not supported               | Check platform compatibility          |

### **Permission Errors**

| Error                        | When It Happens        | How to Fix                            |
| ---------------------------- | ---------------------- | ------------------------------------- |
| `MicrophonePermissionDenied` | User denied mic access | Request permission, guide to settings |

### **Recording State Errors**

| Error                            | When It Happens                      | How to Fix                              |
| -------------------------------- | ------------------------------------ | --------------------------------------- |
| `RecordingAlreadyStarted`        | Start called while recording         | Check if recording before starting      |
| `NotCurrentlyRecording`          | Stop/query called when not recording | Check recording state first             |
| `NotPaused`                      | Resume called when not paused        | Only resume if paused                   |
| `CantEditSettingsWhileRecording` | Changing settings during recording   | Stop recording before changing settings |

### **Runtime Errors**

| Error               | When It Happens          | How to Fix                     |
| ------------------- | ------------------------ | ------------------------------ |
| `RecordingError`    | Failure during recording | Check logs, report issue       |
| `PhotoCaptureError` | Photo capture failed     | Retry or check camera state    |
| `StreamingError`    | Streaming failure        | Check network, streamer config |
| `EncodingError`     | Encoder failure          | Reduce quality settings        |
| `MicrophoneError`   | Mic input failure        | Check device, permissions      |

### **Storage Errors**

| Error                            | When It Happens             | How to Fix                    |
| -------------------------------- | --------------------------- | ----------------------------- |
| `NotEnoughStorageSpace`          | Insufficient disk space     | Free up space, reduce quality |
| `FailedToCopyRecordingToGallery` | Can't save video to gallery | Check permissions, storage    |
| `FailedToCopyPhotoToGallery`     | Can't save photo to gallery | Check permissions, storage    |

### **Missing Features**

| Error                    | When It Happens                 | How to Fix                    |
| ------------------------ | ------------------------------- | ----------------------------- |
| `StreamerNotImplemented` | Streaming package not installed | Install LCK Streaming package |

### **Camera/Monitor Errors**

| Error               | When It Happens    | How to Fix                             |
| ------------------- | ------------------ | -------------------------------------- |
| `CameraIdNotFound`  | Invalid camera ID  | Use valid camera from `GetCameras()`   |
| `MonitorIdNotFound` | Invalid monitor ID | Use valid monitor from `GetMonitors()` |

### **Unknown**

| Error          | When It Happens    | How to Fix                        |
| -------------- | ------------------ | --------------------------------- |
| `UnknownError` | Unexpected failure | Check logs, report to LIV support |

***

## Complete Error Reference

| Error Code                       | Value | Description                            |
| -------------------------------- | ----- | -------------------------------------- |
| `ServiceNotCreated`              | 1     | LCK service not initialized before use |
| `ServiceDisposed`                | 2     | LCK service already disposed           |
| `InvalidDescriptor`              | 3     | Invalid `LckDescriptor` configuration  |
| `CameraIdNotFound`               | 4     | Camera ID doesn't exist                |
| `MonitorIdNotFound`              | 5     | Monitor ID doesn't exist               |
| `MicrophonePermissionDenied`     | 6     | Microphone permission denied           |
| `RecordingAlreadyStarted`        | 7     | Recording already in progress          |
| `NotCurrentlyRecording`          | 8     | No active recording                    |
| `NotPaused`                      | 9     | Recording not paused (can't resume)    |
| `RecordingError`                 | 10    | General recording failure              |
| `PhotoCaptureError`              | 11    | Photo capture failed                   |
| `CantEditSettingsWhileRecording` | 12    | Settings locked during recording       |
| `NotEnoughStorageSpace`          | 13    | Insufficient disk space                |
| `FailedToCopyRecordingToGallery` | 14    | Can't save video to gallery            |
| `FailedToCopyPhotoToGallery`     | 15    | Can't save photo to gallery            |
| `UnsupportedGraphicsApi`         | 16    | Graphics API not supported             |
| `UnsupportedPlatform`            | 17    | Platform not supported                 |
| `MicrophoneError`                | 18    | Microphone runtime error               |
| `StreamerNotImplemented`         | 19    | Streaming package missing              |
| `StreamingError`                 | 20    | Streaming failure                      |
| `EncodingError`                  | 21    | Encoding failure                       |
| `UnknownError`                   | 22    | Unknown/unspecified error              |

***

## Best Practices

<Check>
  **Always check IsOk** — Never assume operations succeed
</Check>

<Check>
  **Log errors** — Include `result.Message` for context
</Check>

<Check>
  **Handle common cases** — Storage, permissions, state conflicts
</Check>

<Check>
  **User-friendly messages** — Don't show raw error codes to users
</Check>

### Good Error Handling Pattern

```csharp theme={null}
var result = lckService.StartRecording();

if (!result.IsOk)
{
    Debug.LogError($"Recording failed: {result.Error} - {result.Message}");
    
    string userMessage = result.Error switch
    {
        LckError.NotEnoughStorageSpace => 
            "Not enough space. Free up storage and try again.",
        LckError.MicrophonePermissionDenied => 
            "Microphone access required. Enable in Settings.",
        LckError.RecordingAlreadyStarted => 
            "Recording already in progress.",
        LckError.UnsupportedGraphicsApi => 
            "Graphics API not supported. Try switching to Vulkan.",
        _ => 
            "Recording failed. Please try again."
    };
    
    ShowErrorDialog(userMessage);
    return;
}

Debug.Log("Recording started successfully");
```

***

## Related

* [LckResult](/api-reference/unity/classes/LckResult) — Contains LckError when operations fail
* [Error Handling Guide](https://docs.liv.tv/api-reference/unity/interfaces/core/ILckCore#error-handling)
