Ensure that the "DocException" message handler, in the API, will always either error or warn (depending on the build) if a valid Error isn't found

Having this present would have made debugging issues 11941 and 12209 so much quicker and easier.
This commit is contained in:
Jonas Jenwald 2020-08-13 13:17:30 +02:00
parent ea5581b70a
commit b26d736809

View File

@ -2271,11 +2271,16 @@ class WorkerTransport {
reason = new UnknownErrorException(ex.message, ex.details); reason = new UnknownErrorException(ex.message, ex.details);
break; break;
} }
if ( if (!(reason instanceof Error)) {
typeof PDFJSDev === "undefined" || const msg = "DocException - expected a valid Error.";
PDFJSDev.test("!PRODUCTION || TESTING") if (
) { typeof PDFJSDev === "undefined" ||
assert(reason instanceof Error, "DocException: expected an Error."); PDFJSDev.test("!PRODUCTION || TESTING")
) {
unreachable(msg);
} else {
warn(msg);
}
} }
loadingTask._capability.reject(reason); loadingTask._capability.reject(reason);
}); });