mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
fix for #2219, "provide a better error message when file= not found/accessible"
summary: create a new Exception class for missing PDF's, use it in place of generic add new MissingPDFException to util.js handle MissingPDF in api.js handle MissingPDF in viewer.js, using new missing_file_error message add new missing_file_error to l10n/en-US/viewer.properties send MissingPDF from WorkerMessageHandler's loadDocument send MissingPDF from GetDocRequest handler
This commit is contained in:
parent
7bd8887860
commit
12af2f9431
5 changed files with 43 additions and 2 deletions
|
@ -130,6 +130,12 @@ var WorkerMessageHandler = {
|
|||
exception: e
|
||||
});
|
||||
|
||||
return;
|
||||
} else if (e instanceof MissingPDFException) {
|
||||
handler.send('MissingPDF', {
|
||||
exception: e
|
||||
});
|
||||
|
||||
return;
|
||||
} else {
|
||||
handler.send('UnknownError', {
|
||||
|
@ -185,8 +191,15 @@ var WorkerMessageHandler = {
|
|||
});
|
||||
},
|
||||
error: function getPDFError(e) {
|
||||
handler.send('DocError', 'Unexpected server response of ' +
|
||||
e.target.status + '.');
|
||||
if (e.target.status == 404) {
|
||||
handler.send('MissingPDF', {
|
||||
exception: new MissingPDFException(
|
||||
'Missing PDF \"' + source.url + '\".')});
|
||||
} else {
|
||||
handler.send('DocError', 'Unexpected server response (' +
|
||||
e.target.status + ') while retrieving PDF \"' +
|
||||
source.url + '\".');
|
||||
}
|
||||
},
|
||||
headers: source.httpHeaders
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue