Log better errors when unable to show attachments
This commit is contained in:
parent
6e7092c294
commit
4090e968b6
3 changed files with 22 additions and 1 deletions
|
@ -29,7 +29,7 @@ describe('Errors', () => {
|
|||
assert.isUndefined(error.stack);
|
||||
|
||||
const formattedError = Errors.toLogFormat(error);
|
||||
assert.strictEqual(formattedError, 'Error: boom');
|
||||
assert.strictEqual(formattedError, 'boom');
|
||||
});
|
||||
|
||||
[0, false, null, undefined].forEach(value => {
|
||||
|
|
|
@ -3,11 +3,17 @@
|
|||
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
import { get, has } from 'lodash';
|
||||
|
||||
export function toLogFormat(error: unknown): string {
|
||||
if (error instanceof Error && error.stack) {
|
||||
return error.stack;
|
||||
}
|
||||
|
||||
if (has(error, 'message')) {
|
||||
return get(error, 'message');
|
||||
}
|
||||
|
||||
return String(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -2138,6 +2138,21 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
|
|||
getAbsoluteAttachmentPath(item.thumbnail?.path ?? ''),
|
||||
}));
|
||||
|
||||
if (!media.length) {
|
||||
log.error(
|
||||
'showLightbox: unable to load attachment',
|
||||
attachments.map(x => ({
|
||||
contentType: x.contentType,
|
||||
error: x.error,
|
||||
flags: x.flags,
|
||||
path: x.path,
|
||||
size: x.size,
|
||||
}))
|
||||
);
|
||||
showToast(ToastUnableToLoadAttachment);
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedMedia =
|
||||
media.find(item => attachment.path === item.path) || media[0];
|
||||
|
||||
|
|
Loading…
Reference in a new issue