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,7 +14,7 @@
*/
import {
assert, FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageKind, info, isArray,
FONT_IDENTITY_MATRIX, IDENTITY_MATRIX, ImageKind, info, isArray,
isLittleEndian, isNum, OPS, shadow, TextRenderingMode, Util, warn
} from '../shared/util';
import { getShadingPatternFromIR, TilingPattern } from './pattern_helper';
@ -1777,7 +1777,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
if (group.matrix) {
currentCtx.transform.apply(currentCtx, group.matrix);
}
assert(group.bbox, 'Bounding box is required.');
if (!group.bbox) {
throw new Error('Bounding box is required.');
}
// Based on the current transform figure out how big the bounding box
// will actually be.