Skip to main content
What you’ll learn:
  • Common error types
  • Error handling patterns
  • Debugging tips

Catching Errors

import { MetorialAPIError } from 'metorial';

try {
    await metorial.withProviderSession(
        provider,
        { serverDeployments: [{ serverDeploymentId: 'dep_123' }] },
        async ({ tools, closeSession }) => {
            // Your logic
            await closeSession();
        }
    );
} catch (error) {
    if (error instanceof MetorialAPIError) {
        console.error(`API Error: ${error.message}`);
    }
}

Common Errors

  • DEPLOYMENT_NOT_FOUND: Invalid deployment ID
  • SESSION_LIMIT_REACHED: Too many concurrent sessions
  • OAUTH_SESSION_EXPIRED: Reauthorization needed
  • RATE_LIMIT_EXCEEDED: Slow down requests