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 (!(reason instanceof Error)) {
const msg = "DocException - expected a valid Error.";
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING") PDFJSDev.test("!PRODUCTION || TESTING")
) { ) {
assert(reason instanceof Error, "DocException: expected an Error."); unreachable(msg);
} else {
warn(msg);
}
} }
loadingTask._capability.reject(reason); loadingTask._capability.reject(reason);
}); });