1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Remove most assert() calls (issue 8506)

This replaces `assert` calls with `throw new FormatError()`/`throw new Error()`.
In a few places, throwing an `Error` (which is what `assert` meant) isn't correct since the enclosing function is supposed to return a `Promise`, hence some cases were changed to `Promise.reject(...)` and similarily for `createPromiseCapability` instances.
This commit is contained in:
Jonas Jenwald 2017-07-20 14:04:54 +02:00
parent 09f04eccda
commit 814fa1dee3
12 changed files with 193 additions and 89 deletions

View file

@ -14,9 +14,9 @@
*/
import {
assert, bytesToString, FONT_IDENTITY_MATRIX, FontType, FormatError, info,
isArray, isInt, isNum, isSpace, MissingDataException, readUint32, shadow,
string32, warn
bytesToString, FONT_IDENTITY_MATRIX, FontType, FormatError, info, isArray,
isInt, isNum, isSpace, MissingDataException, readUint32, shadow, string32,
warn
} from '../shared/util';
import {
CFF, CFFCharset, CFFCompiler, CFFHeader, CFFIndex, CFFParser, CFFPrivateDict,
@ -2286,7 +2286,9 @@ var Font = (function FontClosure() {
var isCidToGidMapEmpty = cidToGidMap.length === 0;
properties.cMap.forEach(function(charCode, cid) {
assert(cid <= 0xffff, 'Max size of CID is 65,535');
if (cid > 0xffff) {
throw new FormatError('Max size of CID is 65,535');
}
var glyphId = -1;
if (isCidToGidMapEmpty) {
glyphId = cid;