Skip to main content

Error Types

The Narada SDK raises specific exceptions for different error conditions. All errors inherit from NaradaError.
from narada import (
    NaradaError,
    NaradaTimeoutError,
    NaradaUnsupportedBrowserError,
    NaradaExtensionMissingError,
    NaradaExtensionUnauthenticatedError,
    NaradaInitializationError
)

Error Handling Examples

Look at the following examples to see how to handle different errors.
Raised when operations exceed timeout limits.
from narada import NaradaTimeoutError

try:
    response = await agent.run(
        prompt='find a specific element',
        timeout=30
    )
except NaradaTimeoutError:
    print("Operation timed out. Try increasing timeout or simplifying the task.")
Raised when using an unsupported browser.
from narada import BrowserEnvironment, NaradaUnsupportedBrowserError

env = BrowserEnvironment()
try:
    await env.start()
except NaradaUnsupportedBrowserError:
    print("Please use Chrome browser. Other browsers are not supported.")
finally:
    await env.close()
Raised when the Chrome extension is not installed.
from narada import BrowserEnvironment, NaradaExtensionMissingError

env = BrowserEnvironment()
try:
    await env.start()
except NaradaExtensionMissingError:
    print("Narada extension not found. Please install it from the Chrome Web Store.")
finally:
    await env.close()
Raised when the extension is not signed in.
from narada import BrowserEnvironment, NaradaExtensionUnauthenticatedError

env = BrowserEnvironment()
try:
    await env.start()
except NaradaExtensionUnauthenticatedError:
    print("Please sign in to your Narada account in the Chrome extension.")
finally:
    await env.close()
Raised when SDK initialization fails.
from narada import BrowserEnvironment, NaradaInitializationError

env = BrowserEnvironment()
try:
    await env.start()
except NaradaInitializationError:
    print("Failed to initialize SDK. Check your API key and internet connection.")
finally:
    await env.close()

Retry Pattern

For transient errors, implement retry logic:
import asyncio
from narada import Agent, BrowserEnvironment, NaradaTimeoutError

async def retry_operation(agent, prompt, max_retries=3):
    for attempt in range(max_retries):
        try:
            return await agent.run(prompt=prompt)
        except NaradaTimeoutError:
            if attempt == max_retries - 1:
                raise
            await agent.reset_agent_state()
            await asyncio.sleep(2 ** attempt)  # Exponential backoff

async def main():
    env = BrowserEnvironment()
    agent = Agent(environment=env)

    try:
        response = await retry_operation(
            agent,
            'search for "python tutorial"'
        )
        print(response.text)
    finally:
        await env.close()

asyncio.run(main())

Best Practices

Catch Specific Errors

Handle specific error types rather than generic exceptions

Implement Retries

Use retry logic for timeout and initialization errors

Log Errors

Log errors with context for debugging

Graceful Degradation

Design fallback behavior when automation fails
Most errors are recoverable. Check the error message and implement appropriate retry or fallback logic.