mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 06:38:07 +02:00
[api-major] Replace MissingPDFException
and UnexpectedResponseException
with one exception
These old exceptions have a fair amount of overlap given how/where they are being used, which is likely because they were introduced at different points in time, hence we can shorten and simplify the code by replacing them with a more general `ResponseException` instead. Besides an error message, the new `ResponseException` instances also include: - A numeric `status` field containing the server response status, similar to the old `UnexpectedResponseException`. - A boolean `missing` field, to allow easily detecting the situations where `MissingPDFException` was previously thrown.
This commit is contained in:
parent
7a57af12e1
commit
75cba72ca6
15 changed files with 65 additions and 92 deletions
|
@ -91,10 +91,10 @@ const PDFViewerApplication = {
|
|||
let key = "pdfjs-loading-error";
|
||||
if (reason instanceof pdfjsLib.InvalidPDFException) {
|
||||
key = "pdfjs-invalid-file-error";
|
||||
} else if (reason instanceof pdfjsLib.MissingPDFException) {
|
||||
key = "pdfjs-missing-file-error";
|
||||
} else if (reason instanceof pdfjsLib.UnexpectedResponseException) {
|
||||
key = "pdfjs-unexpected-response-error";
|
||||
} else if (reason instanceof pdfjsLib.ResponseException) {
|
||||
key = reason.missing
|
||||
? "pdfjs-missing-file-error"
|
||||
: "pdfjs-unexpected-response-error";
|
||||
}
|
||||
self.l10n.get(key).then(msg => {
|
||||
self.error(msg, { message: reason?.message });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue