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

@ -529,7 +529,7 @@ export async function downloadEphemeralPack(
}
log.error(
`Ephemeral download error for sticker pack ${redactPackId(packId)}:`,
error && error.stack ? error.stack : error
Errors.toLogFormat(error)
);
}
}
@ -554,7 +554,7 @@ export async function downloadStickerPack(
} catch (error) {
log.error(
'doDownloadStickerPack threw an error:',
error && error.stack ? error.stack : error
Errors.toLogFormat(error)
);
}
});
@ -696,7 +696,7 @@ async function doDownloadStickerPack(
} catch (error) {
log.error(
`Error downloading manifest for sticker pack ${redactPackId(packId)}:`,
error && error.stack ? error.stack : error
Errors.toLogFormat(error)
);
const pack = {
@ -779,7 +779,7 @@ async function doDownloadStickerPack(
} catch (error) {
log.error(
`Error downloading stickers for sticker pack ${redactPackId(packId)}:`,
error && error.stack ? error.stack : error
Errors.toLogFormat(error)
);
const errorStatus = 'error';

View file

@ -4,15 +4,20 @@
import { get, has } from 'lodash';
export function toLogFormat(error: unknown): string {
let result = '';
if (error instanceof Error && error.stack) {
return error.stack;
result = error.stack;
} else if (has(error, 'message')) {
result = get(error, 'message');
} else {
result = String(error);
}
if (has(error, 'message')) {
return get(error, 'message');
if (has(error, 'cause')) {
result += `\nCaused by: ${String(get(error, 'cause'))}`;
}
return String(error);
return result;
}
export class ProfileDecryptError extends Error {}