Skip to main content

错误处理

🌐 Error Handling

Mastra 客户端 SDK 包含内置的重试机制和错误处理功能。

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

错误处理
Direct link to 错误处理

🌐 Error Handling

所有 API 方法都可能抛出错误,你可以捕获并处理这些错误:

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

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