1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #8205 from Snuffleupagus/built-in-CMap-errors

Improve the error handling when loading of built-in CMap files fail (PR 8064 follow-up)
This commit is contained in:
Tim van der Meij 2017-03-30 23:01:13 +02:00 committed by GitHub
commit 8cee63df5d
3 changed files with 48 additions and 6 deletions

View file

@ -954,7 +954,7 @@ var CMapFactory = (function CMapFactoryClosure() {
return Promise.resolve(new IdentityCMap(true, 2));
}
if (BUILT_IN_CMAPS.indexOf(name) === -1) {
return Promise.reject(new Error('Unknown cMap name: ' + name));
return Promise.reject(new Error('Unknown CMap name: ' + name));
}
assert(fetchBuiltInCMap, 'Built-in CMap parameters are not provided.');

View file

@ -90,8 +90,10 @@ var DOMCMapReaderFactory = (function DOMCMapReaderFactoryClosure() {
request.responseType = 'arraybuffer';
}
request.onreadystatechange = function () {
if (request.readyState === XMLHttpRequest.DONE &&
(request.status === 200 || request.status === 0)) {
if (request.readyState !== XMLHttpRequest.DONE) {
return;
}
if (request.status === 200 || request.status === 0) {
var data;
if (this.isCompressed && request.response) {
data = new Uint8Array(request.response);
@ -106,10 +108,10 @@ var DOMCMapReaderFactory = (function DOMCMapReaderFactoryClosure() {
});
return;
}
reject(new Error('Unable to load ' +
(this.isCompressed ? 'binary ' : '') +
'CMap at: ' + url));
}
reject(new Error('Unable to load ' +
(this.isCompressed ? 'binary ' : '') +
'CMap at: ' + url));
}.bind(this);
request.send(null);