Skip to Content
ReferenceClient SDKError Handling

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:

try { const agent = mastraClient.getAgent("agent-id"); const response = await agent.generate({ messages: [{ role: "user", content: "Hello" }], }); } catch (error) { console.error("An error occurred:", error.message); }