docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Synchronous errors

    Handle synchronous exceptions thrown by the Instant Games SDK in C# or JavaScript.

    Synchronous exceptions refer to all errors except those thrown while awaiting an asynchronous task. Most exceptions thrown in C# fall into this category.

    Error handling

    If the error occurs in C#, handle it with the try/catch mechanism.

    If the error occurs in JavaScript, it's represented by JsException. Even though the JsException originates in JavaScript, you can still handle it in C# using try/catch:

    try
    {
        // call an SDK endpoint or access an SDK object property
    }
    catch (JsException e)
    {
        // respond to the failure
    }
    

    Additional resources

    • Error handling
    • Asynchronous errors
    • Synchronous errors thrown by async methods
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)