Remove the makeReasonSerializable
helper function, and use wrapReason
instead, in src/shared/message_handler.js
Since `wrapReason` and `makeReasonSerializable` are essentially functionally equivalent it doesn't seem necessary to keep both of them around, especially when `makeReasonSerializable` only has a *single* call-site.
This commit is contained in:
parent
4e6a9b54c7
commit
f71ea2de0e
@ -48,22 +48,13 @@ function wrapReason(reason) {
|
||||
return new MissingPDFException(reason.message);
|
||||
case 'UnexpectedResponseException':
|
||||
return new UnexpectedResponseException(reason.message, reason.status);
|
||||
default:
|
||||
case 'UnknownErrorException':
|
||||
return new UnknownErrorException(reason.message, reason.details);
|
||||
default:
|
||||
return new UnknownErrorException(reason.message, reason.toString());
|
||||
}
|
||||
}
|
||||
|
||||
function makeReasonSerializable(reason) {
|
||||
if (!(reason instanceof Error) ||
|
||||
reason instanceof AbortException ||
|
||||
reason instanceof MissingPDFException ||
|
||||
reason instanceof UnexpectedResponseException ||
|
||||
reason instanceof UnknownErrorException) {
|
||||
return reason;
|
||||
}
|
||||
return new UnknownErrorException(reason.message, reason.toString());
|
||||
}
|
||||
|
||||
function resolveOrReject(capability, data) {
|
||||
if (data.success) {
|
||||
capability.resolve();
|
||||
@ -125,7 +116,7 @@ function MessageHandler(sourceName, targetName, comObj) {
|
||||
targetName,
|
||||
isReply: true,
|
||||
callbackId: data.callbackId,
|
||||
error: makeReasonSerializable(reason),
|
||||
error: wrapReason(reason),
|
||||
});
|
||||
});
|
||||
} else if (data.streamId) {
|
||||
|
Loading…
Reference in New Issue
Block a user