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.

Retry Pattern

For transient errors, implement retry logic:

import asyncio
from narada import Narada, NaradaTimeoutError

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

async def main():
    async with Narada() as narada:
        response = await retry_operation(
            narada,
            '/Operator search for "python tutorial"'
        )
        print(response)

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.