> ## 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.

# CoreError

> High-level error categories from LckCore operations like initialization and authentication failures.

## What Problem Does This Solve?

Before you can use the LCK SDK, you need to initialize it with `LckCore.Initialize()`. This process can fail for several reasons: missing tracking ID, invalid arguments, network issues, or user not logged in.

`CoreError` provides specific error codes for these initialization and core-level failures so you can diagnose and fix setup problems.

## When to Use This

You'll encounter `CoreError` when:

* Initializing the SDK with `LckCore.Initialize()`
* Operations require authentication (user login)
* Passing invalid arguments to core methods
* SDK encounters internal errors during setup

These are **setup-time errors**, not runtime recording errors (those use `LckError`).

***

## Quick Example

```csharp theme={null}
var gameInfo = new GameInfo { /* ... */ };
var result = LckCore.Initialize("tracking-id-123", gameInfo);

if (!result.IsOk)
{
    Debug.LogError($"Initialization failed: {result.Message}");
    
    switch (result.Error)
    {
        case CoreError.MissingTrackingId:
            Debug.LogError("No tracking ID provided");
            break;
        case CoreError.InvalidArgument:
            Debug.LogError("Invalid GameInfo configuration");
            break;
        case CoreError.UserNotLoggedIn:
            Debug.LogError("User must be logged in");
            break;
        case CoreError.InternalError:
            Debug.LogError("SDK internal error");
            break;
    }
    
    return;
}

Debug.Log("LCK initialized successfully");
```

***

## Error Breakdown

### MissingTrackingId

**When it happens:** You passed `null`, empty string, or invalid tracking ID to `Initialize()`

**How to fix:**

```csharp theme={null}
// Bad
LckCore.Initialize(null, gameInfo);          // Error
LckCore.Initialize("", gameInfo);            // Error

// Good
LckCore.Initialize("your-tracking-id", gameInfo);  // OK
```

Your tracking ID comes from the LIV Developer Dashboard. Get it from `https://dashboard.liv.tv/dev/`

***

### InvalidArgument

**When it happens:** You passed invalid data to a core method (bad GameInfo, null parameters, etc.)

**How to fix:**

```csharp theme={null}
// Bad
LckCore.Initialize("tracking-id", null);     // Error - null GameInfo

// Good
var gameInfo = new GameInfo
{
    GameName = "My Game",
    GameVersion = "1.0.0",
    ProjectName = "MyProject",
    CompanyName = "Studio",
    EngineVersion = Application.unityVersion,
    RenderPipeline = "URP",
    GraphicsAPI = SystemInfo.graphicsDeviceType.ToString()
};

LckCore.Initialize("tracking-id", gameInfo); // OK
```

Validate your inputs before calling core methods.

***

### UserNotLoggedIn

**When it happens:** Operation requires authentication but user hasn't logged in

**How to fix:**

```csharp theme={null}
// Check login status
bool isLoggedIn = LckCore.IsUserLoggedIn();

if (!isLoggedIn)
{
    // Prompt user to log in
    ShowLoginDialog();
    return;
}

// Proceed with authenticated operation
```

Some SDK features require the user to be logged into their LIV account.

***

### InternalError

**When it happens:** Unexpected SDK internal failure

**What to do:**

1. Check the full error message: `result.Message`
2. Look for more details in Unity console or device logs
3. Report to LIV support with:
   * Error message
   * SDK version
   * Platform (Android, Windows, etc.)
   * Steps to reproduce

```csharp theme={null}
if (result.Error == CoreError.InternalError)
{
    Debug.LogError($"Internal error: {result.Message}");
    Debug.LogError($"Platform: {Application.platform}");
    Debug.LogError($"SDK Version: [your SDK version]");
    
    // Report to analytics/crash reporting
    ReportError("LCK Internal Error", result.Message);
}
```

***

## Complete Error Reference

| Error               | Value | Description                       | Fix                                      |
| ------------------- | ----- | --------------------------------- | ---------------------------------------- |
| `InternalError`     | 0     | Unexpected SDK internal error     | Check logs, report to support            |
| `MissingTrackingId` | 1     | Tracking ID missing or invalid    | Provide valid tracking ID from dashboard |
| `InvalidArgument`   | 2     | Invalid argument passed to method | Validate inputs (GameInfo, etc.)         |
| `UserNotLoggedIn`   | 3     | User authentication required      | Prompt user to log in                    |

***

## Common Initialization Pattern

```csharp theme={null}
public class LCKManager : MonoBehaviour
{
    [SerializeField] private string trackingId = "your-tracking-id-here";
    
    void Awake()
    {
        InitializeLCK();
    }
    
    void InitializeLCK()
    {
        // Validate tracking ID
        if (string.IsNullOrEmpty(trackingId))
        {
            Debug.LogError("Tracking ID not set in inspector!");
            return;
        }
        
        // Create GameInfo
        var gameInfo = new GameInfo
        {
            GameName = Application.productName,
            GameVersion = Application.version,
            ProjectName = Application.productName,
            CompanyName = Application.companyName,
            EngineVersion = Application.unityVersion,
            RenderPipeline = GetRenderPipeline(),
            GraphicsAPI = SystemInfo.graphicsDeviceType.ToString()
        };
        
        // Initialize
        var result = LckCore.Initialize(trackingId, gameInfo);
        
        if (!result.IsOk)
        {
            HandleInitializationError(result);
            return;
        }
        
        Debug.Log("LCK initialized successfully");
    }
    
    void HandleInitializationError(LckResult result)
    {
        Debug.LogError($"LCK initialization failed: {result.Message}");
        
        switch (result.Error)
        {
            case CoreError.MissingTrackingId:
                ShowError("Configuration error: Missing tracking ID");
                break;
                
            case CoreError.InvalidArgument:
                ShowError("Configuration error: Invalid setup");
                break;
                
            case CoreError.UserNotLoggedIn:
                ShowLoginPrompt();
                break;
                
            case CoreError.InternalError:
                ShowError("SDK initialization failed. Please restart.");
                ReportToAnalytics("LCK_Init_Internal_Error", result.Message);
                break;
        }
    }
    
    string GetRenderPipeline()
    {
        #if UNITY_PIPELINE_URP
            return "URP";
        #elif UNITY_PIPELINE_HDRP
            return "HDRP";
        #else
            return "Built-in";
        #endif
    }
}
```

***

## Best Practices

<Check>
  **Validate inputs** — Check tracking ID and GameInfo before initializing
</Check>

<Check>
  **Initialize early** — Call in `Awake()` or `Start()` before using SDK
</Check>

<Check>
  **Handle all errors** — Don't ignore initialization failures
</Check>

<Check>
  **Log details** — Include platform, SDK version in error reports
</Check>

### Don't ignore initialization errors

```csharp theme={null}
// Bad - ignoring failure
LckCore.Initialize(trackingId, gameInfo);

// Good - checking result
var result = LckCore.Initialize(trackingId, gameInfo);
if (!result.IsOk)
{
    Debug.LogError($"Init failed: {result.Message}");
    return; // Don't proceed if init failed
}
```

***

## Debugging Tips

### Check if already initialized

```csharp theme={null}
if (LckCore.IsInitialized())
{
    Debug.Log("LCK already initialized");
    return;
}
```

### Validate tracking ID format

```csharp theme={null}
bool IsValidTrackingId(string id)
{
    return !string.IsNullOrWhiteSpace(id) && id.Length > 10;
}

if (!IsValidTrackingId(trackingId))
{
    Debug.LogError("Invalid tracking ID format");
}
```

### Test with mock data

```csharp theme={null}
#if UNITY_EDITOR
    // Use test tracking ID in editor
    trackingId = "test-tracking-id-editor";
#endif
```

***

## Related

* [GameInfo](/api-reference/unity/structs/core/GameInfo) — Required initialization parameter
* [LckError](/api-reference/unity/enums/LckError) — Runtime operation errors
* [Initialization Guide](/unity/installation) — Complete setup walkthrough
