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,
originalMessage?: string
): void {
const isError = errorMessage instanceof ProtocolError;
const message = isError ? errorMessage.message : errorMessage;
const error = isError ? errorMessage : callback.error;
let error: ProtocolError;
let message: string;
if (errorMessage instanceof ProtocolError) {
error = errorMessage;
error.cause = callback.error;
message = errorMessage.message;
} else {
error = callback.error;
message = errorMessage;
}
callback.reject(
rewriteError(