From 74de4ea6f6e1c123b571d39149483e732a75f605 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 22 Oct 2020 15:30:28 -0700 Subject: [PATCH] Capture original error stack when sending messages --- ts/textsecure/MessageReceiver.ts | 1 + ts/textsecure/OutgoingMessage.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ts/textsecure/MessageReceiver.ts b/ts/textsecure/MessageReceiver.ts index 5ccbc0632dc8..4295e7723f95 100644 --- a/ts/textsecure/MessageReceiver.ts +++ b/ts/textsecure/MessageReceiver.ts @@ -74,6 +74,7 @@ declare global { } interface Error { reason?: any; + stackForLog?: string; sender?: SignalProtocolAddressClass; senderUuid?: SignalProtocolAddressClass; } diff --git a/ts/textsecure/OutgoingMessage.ts b/ts/textsecure/OutgoingMessage.ts index 5792fecbb70f..36d249bece47 100644 --- a/ts/textsecure/OutgoingMessage.ts +++ b/ts/textsecure/OutgoingMessage.ts @@ -113,7 +113,13 @@ export default class OutgoingMessage { } } - registerError(identifier: string, reason: string, error?: Error): void { + registerError( + identifier: string, + reason: string, + providedError?: Error + ): void { + let error = providedError; + if (!error || (error.name === 'HTTPError' && error.code !== 404)) { error = new OutgoingMessageError( identifier, @@ -124,6 +130,8 @@ export default class OutgoingMessage { } error.reason = reason; + error.stackForLog = providedError ? providedError.stack : undefined; + this.errors[this.errors.length] = error; this.numberCompleted(); }