Back to Mastra

Reference: Error handling | Client SDK

docs/src/content/en/reference/client-js/error-handling.mdx

2025-12-18387 B
Original Source

Error handling

The Mastra Client SDK includes built-in retry mechanism and error handling capabilities.

Error handling

All API methods can throw errors that you can catch and handle:

typescript
try {
  const agent = mastraClient.getAgent('agent-id')
  const response = await agent.generate('Hello')
} catch (error) {
  console.error('An error occurred:', error.message)
}