mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Error handling
This commit is contained in:
@@ -386,18 +386,22 @@ server.tool(
|
||||
url: z.string().optional().default('http://localhost:3000'),
|
||||
},
|
||||
async ({url}) => {
|
||||
|
||||
try {
|
||||
const componentTree = await parseReactComponentTree(url);
|
||||
const componentTree = await parseReactComponentTree(url);
|
||||
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text' as const,
|
||||
text: componentTree,
|
||||
},
|
||||
],
|
||||
};
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: 'text' as const,
|
||||
text: componentTree,
|
||||
},
|
||||
],
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
isError: true,
|
||||
content: [{type: 'text' as const, text: `Error: ${err.stack}`}],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user