Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert news generation errors to warnings #1820

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/helpers/gemini_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class GeminiClient {

return text;
} catch (e) {
logger.error(
logger.warn(
`Failed to fetch getPostSummary(). locale = ${locale}. newsRange = ${newsRange}. e = ${e}`,
);
return "";
Expand Down
9 changes: 8 additions & 1 deletion src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export function friendlyFormattedDate(date: Date, guildID: string): string {
* @param maxRetries - retries of job before throwing
* @param firstTry - whether this is the first try
* @param delayDuration - time (in ms) before attempting job retry
* @param sendError - whether to send a warning or error
* @returns the result of job
*/
export async function retryJob<Type>(
Expand All @@ -333,13 +334,19 @@ export async function retryJob<Type>(
maxRetries: number,
firstTry: boolean,
delayDuration?: number,
sendError = true,
): Promise<Type> {
if (!firstTry && delayDuration) {
await delay(delayDuration);
}

return job(...jobArgs).catch((err) => {
logger.error(`err = ${err}`);
if (sendError) {
logger.error(`err = ${err}`);
} else {
logger.warn(`err = ${err}`);
}

if (maxRetries <= 0) {
throw err;
}
Expand Down
3 changes: 2 additions & 1 deletion src/kmq_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default class ServiceWorker extends BaseServiceWorker {
);

if (summary === "") {
logger.error(
logger.warn(
`Error generating news for ${locale} ${range}`,
);
return Promise.reject(
Expand Down Expand Up @@ -170,6 +170,7 @@ export default class ServiceWorker extends BaseServiceWorker {
3,
true,
60000,
false,
);
}),
);
Expand Down
Loading