Merge pull request #14607 from Snuffleupagus/wrapReason-unreachable

Simplify the `wrapReason` helper function
This commit is contained in:
Tim van der Meij 2022-02-26 15:37:29 +01:00 committed by GitHub
commit f782f5e5bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ import {
PasswordException, PasswordException,
UnexpectedResponseException, UnexpectedResponseException,
UnknownErrorException, UnknownErrorException,
warn, unreachable,
} from "./util.js"; } from "./util.js";
const CallbackKind = { const CallbackKind = {
@ -49,17 +49,10 @@ function wrapReason(reason) {
(typeof reason === "object" && reason !== null) (typeof reason === "object" && reason !== null)
) )
) { ) {
if ( unreachable(
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
throw new Error(
'wrapReason: Expected "reason" to be a (possibly cloned) Error.' 'wrapReason: Expected "reason" to be a (possibly cloned) Error.'
); );
} }
warn('wrapReason: Expected "reason" to be a (possibly cloned) Error.');
return reason;
}
switch (reason.name) { switch (reason.name) {
case "AbortException": case "AbortException":
return new AbortException(reason.message); return new AbortException(reason.message);