Improve error message for non-existent local files
I received multiple reports about the following cryptic error in the Chrome extension when the user tried to open a local file: > PDF.js v1.1.527 (build: 2096a2a) > Message: Cannot read property 'Symbol(Symbol.iterator)' of null This error most likely originated from core/stream.js: function Stream(arrayBuffer, start, length, dict) { this.bytes = (arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer)); ^^^^^^^^^^^ `arrayBuffer` is `null`, and that in turn is caused by the fact that for non-existing files, there is no data. I've applied two fixes: 1. Never call onDone with a void buffer, but call the error handler instead. 2. Show a sensible error message for local files with status = 0.
This commit is contained in:
parent
07067cf078
commit
c604cc22d1
@ -245,11 +245,13 @@ var NetworkManager = (function NetworkManagerClosure() {
|
||||
});
|
||||
} else if (pendingRequest.onProgressiveData) {
|
||||
pendingRequest.onDone(null);
|
||||
} else {
|
||||
} else if (chunk) {
|
||||
pendingRequest.onDone({
|
||||
begin: 0,
|
||||
chunk: chunk
|
||||
});
|
||||
} else if (pendingRequest.onError) {
|
||||
pendingRequest.onError(xhr.status);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -236,7 +236,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
|
||||
onError: function onError(status) {
|
||||
var exception;
|
||||
if (status === 404) {
|
||||
if (status === 404 || status === 0 && /^file:/.test(source.url)) {
|
||||
exception = new MissingPDFException('Missing PDF "' +
|
||||
source.url + '".');
|
||||
handler.send('MissingPDF', exception);
|
||||
|
Loading…
x
Reference in New Issue
Block a user