Capture original error stack when sending messages

This commit is contained in:
Scott Nonnenberg 2020-10-22 15:30:28 -07:00
parent a4c6003f34
commit 74de4ea6f6
2 changed files with 10 additions and 1 deletions

View file

@ -74,6 +74,7 @@ declare global {
}
interface Error {
reason?: any;
stackForLog?: string;
sender?: SignalProtocolAddressClass;
senderUuid?: SignalProtocolAddressClass;
}

View file

@ -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();
}