chore: add cause for callback errors (#10823)

This commit is contained in:
Nikolay Vitkov 2023-08-31 15:54:57 +02:00 committed by GitHub
parent d91c3ed675
commit 517c4753f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -160,9 +160,16 @@ export class CallbackRegistry {
errorMessage: string | ProtocolError, errorMessage: string | ProtocolError,
originalMessage?: string originalMessage?: string
): void { ): void {
const isError = errorMessage instanceof ProtocolError; let error: ProtocolError;
const message = isError ? errorMessage.message : errorMessage; let message: string;
const error = isError ? errorMessage : callback.error; if (errorMessage instanceof ProtocolError) {
error = errorMessage;
error.cause = callback.error;
message = errorMessage.message;
} else {
error = callback.error;
message = errorMessage;
}
callback.reject( callback.reject(
rewriteError( rewriteError(