Improve error handling during group sends

This commit is contained in:
Fedor Indutny 2022-11-22 10:43:43 -08:00 committed by GitHub
parent f0a3735ca2
commit 991580a1ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
58 changed files with 299 additions and 324 deletions

View file

@ -11,6 +11,7 @@ import type {
MaybeGrabLinkPreviewOptionsType,
AddLinkPreviewOptionsType,
} from '../types/LinkPreview';
import * as Errors from '../types/errors';
import type { StickerPackType as StickerPackDBType } from '../sql/Interface';
import type { MIMEType } from '../types/MIME';
import * as Bytes from '../Bytes';
@ -216,7 +217,7 @@ export async function addLinkPreview(
} catch (error) {
log.error(
'Problem loading link preview, disabling.',
error && error.stack ? error.stack : error
Errors.toLogFormat(error)
);
disableLinkPreviews = true;
removeLinkPreview();
@ -455,10 +456,7 @@ async function getStickerPackPreview(
url,
};
} catch (error) {
log.error(
'getStickerPackPreview error:',
error && error.stack ? error.stack : error
);
log.error('getStickerPackPreview error:', Errors.toLogFormat(error));
return null;
} finally {
if (id) {
@ -530,7 +528,7 @@ async function getGroupPreview(
),
};
} catch (error) {
const errorString = error && error.stack ? error.stack : error;
const errorString = Errors.toLogFormat(error);
log.error(
`getGroupPreview/${logId}: Failed to fetch avatar ${errorString}`
);