Skip to content

Commit 7d73fa2

Browse files
committed
Improve error handling in getActor tool by catching specific ApifyApiError
1 parent bca99ea commit 7d73fa2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/tools/actor.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
22
import { Ajv } from 'ajv';
3-
import type { ActorCallOptions, ActorRun, Dataset, PaginatedList } from 'apify-client';
3+
import { type ActorCallOptions, type ActorRun, ApifyApiError, type Dataset, type PaginatedList } from 'apify-client';
44
import { z } from 'zod';
55
import zodToJsonSchema from 'zod-to-json-schema';
66

@@ -256,8 +256,11 @@ export const getActor: ToolEntry = {
256256
return { content: [{ type: 'text', text: `Actor '${actorId}' not found.` }] };
257257
}
258258
return { content: [{ type: 'text', text: JSON.stringify(actor) }] };
259-
} catch {
260-
return { content: [{ type: 'text', text: `Invalid actor ID or actor not found.` }] };
259+
} catch (error) {
260+
if (error instanceof ApifyApiError) {
261+
return { content: [{ type: 'text', text: `Failed to get actor details: ${error.message}` }] };
262+
}
263+
throw error;
261264
}
262265
},
263266
} as InternalTool,

0 commit comments

Comments
 (0)