mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-17 21:25:56 +08:00
fix: logging for search error
This commit is contained in:
parent
e0e37ad4d7
commit
8ec8c1e718
@ -451,6 +451,7 @@ ${this.content}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const r = await this.braveSearchService.webSearch(query);
|
const r = await this.braveSearchService.webSearch(query);
|
||||||
|
|
||||||
const nowDate = new Date();
|
const nowDate = new Date();
|
||||||
@ -466,5 +467,15 @@ ${this.content}
|
|||||||
});
|
});
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
|
} catch (err: any) {
|
||||||
|
if (cache) {
|
||||||
|
this.logger.warn(`Failed to fetch search result, but a stale cache is available. falling back to stale cache`, { err: marshalErrorLike(err) });
|
||||||
|
|
||||||
|
return cache.response as WebSearchApiResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AsyncService, DownstreamServiceFailureError } from 'civkit';
|
import { AsyncService, DownstreamServiceFailureError, marshalErrorLike } from 'civkit';
|
||||||
import { singleton } from 'tsyringe';
|
import { singleton } from 'tsyringe';
|
||||||
import { Logger } from '../shared/services/logger';
|
import { Logger } from '../shared/services/logger';
|
||||||
import { SecretExposer } from '../shared/services/secrets';
|
import { SecretExposer } from '../shared/services/secrets';
|
||||||
@ -62,8 +62,10 @@ export class BraveSearchService extends AsyncService {
|
|||||||
const r = await this.braveSearchHTTP.webSearch(query, { headers: extraHeaders as Record<string, string> });
|
const r = await this.braveSearchHTTP.webSearch(query, { headers: extraHeaders as Record<string, string> });
|
||||||
|
|
||||||
return r.parsed;
|
return r.parsed;
|
||||||
} catch (err) {
|
} catch (err: any) {
|
||||||
throw new DownstreamServiceFailureError({ message: `Search failed`, cause: err });
|
this.logger.error(`Web search failed: ${err?.message}`, { err: marshalErrorLike(err) });
|
||||||
|
|
||||||
|
throw new DownstreamServiceFailureError({ message: `Search failed` });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user