[MessageHandler] Add a non-PRODUCTION/TESTING check to ensure that wrapReason
is called with a valid reason
There shouldn't be any situation where `reason` isn't either an `Error`, or a cloned "Error" sent via `postMessage`.
This commit is contained in:
parent
9201c8dad4
commit
eabedab38e
@ -31,7 +31,13 @@ const StreamKind = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function wrapReason(reason) {
|
function wrapReason(reason) {
|
||||||
if (typeof reason !== 'object') {
|
if (typeof PDFJSDev === 'undefined' ||
|
||||||
|
PDFJSDev.test('!PRODUCTION || TESTING')) {
|
||||||
|
assert(reason instanceof Error ||
|
||||||
|
(typeof reason === 'object' && reason !== null),
|
||||||
|
'wrapReason: Expected "reason" to be a (possibly cloned) Error.');
|
||||||
|
}
|
||||||
|
if (typeof reason !== 'object' || reason === null) {
|
||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
switch (reason.name) {
|
switch (reason.name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user