Skip to content

Commit

Permalink
feat(tool): improve arxiv error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomas2D committed Sep 3, 2024
1 parent 777c684 commit d4faf00
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tools/arxiv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,15 @@ export class ArXivTool extends Tool<ArXivToolOutput, ToolOptions, ToolRunOptions
removeNSPrefix: true,
textNodeName: "#text",
trimValues: true,
ignoreDeclaration: true,
});

const text = await response.text();
const parsedData = parser.parse(text);

if (!response.ok) {
throw new ToolError("Request to ArXiv API has failed!", [
new Error(JSON.stringify(getProp(parsedData, ["entry"], parsedData), null, 2)),
new Error(JSON.stringify(getProp(parsedData, ["feed", "entry"], parsedData), null, 2)),
]);
}

Expand Down

0 comments on commit d4faf00

Please sign in to comment.