mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2025-12-26 06:28:56 +08:00
fix: enhance error handling for unauthorized Jina API key
This commit is contained in:
parent
8e3d34bcca
commit
034e984d15
@ -46,6 +46,7 @@ import { buildImageReferences, buildReferences } from "./tools/build-ref";
|
|||||||
import { logInfo, logError, logDebug, logWarning } from './logging';
|
import { logInfo, logError, logDebug, logWarning } from './logging';
|
||||||
import { researchPlan } from './tools/research-planner';
|
import { researchPlan } from './tools/research-planner';
|
||||||
import { reduceAnswers } from './tools/reducer';
|
import { reduceAnswers } from './tools/reducer';
|
||||||
|
import { AxiosError } from 'axios';
|
||||||
|
|
||||||
async function wait(seconds: number) {
|
async function wait(seconds: number) {
|
||||||
logDebug(`Waiting ${seconds}s...`);
|
logDebug(`Waiting ${seconds}s...`);
|
||||||
@ -323,6 +324,10 @@ async function executeSearchQueries(
|
|||||||
query,
|
query,
|
||||||
error: error instanceof Error ? error.message : String(error)
|
error: error instanceof Error ? error.message : String(error)
|
||||||
});
|
});
|
||||||
|
// check if the error is 401
|
||||||
|
if (error instanceof AxiosError && error.response?.status === 401 && (searchProvider === 'jina' || searchProvider === 'arxiv')) {
|
||||||
|
throw new Error('Unauthorized Jina API key');
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
} finally {
|
} finally {
|
||||||
await wait(STEP_SLEEP);
|
await wait(STEP_SLEEP);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user