1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Removes error()

This commit is contained in:
Yury Delendik 2017-06-28 13:51:31 -07:00
parent ac9802809c
commit d028c26210
24 changed files with 318 additions and 260 deletions

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { error, info, isArray, isBool } from '../shared/util';
import { FormatError, info, isArray, isBool } from '../shared/util';
import { isDict, isStream } from './primitives';
import { PostScriptLexer, PostScriptParser } from './ps_parser';
@ -69,7 +69,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var typeNum = dict.get('FunctionType');
var typeFn = types[typeNum];
if (!typeFn) {
error('Unknown type of function');
throw new FormatError('Unknown type of function');
}
return typeFn.call(this, fn, dict, xref);
@ -128,7 +128,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var range = dict.getArray('Range');
if (!domain || !range) {
error('No domain or range');
throw new FormatError('No domain or range');
}
var inputSize = domain.length / 2;
@ -263,7 +263,8 @@ var PDFFunction = (function PDFFunctionClosure() {
var n = dict.get('N');
if (!isArray(c0) || !isArray(c1)) {
error('Illegal dictionary for interpolated function');
throw new FormatError(
'Illegal dictionary for interpolated function');
}
var length = c0.length;
@ -297,12 +298,12 @@ var PDFFunction = (function PDFFunctionClosure() {
var domain = dict.getArray('Domain');
if (!domain) {
error('No domain');
throw new FormatError('No domain');
}
var inputSize = domain.length / 2;
if (inputSize !== 1) {
error('Bad domain for stiched function');
throw new FormatError('Bad domain for stiched function');
}
var fnRefs = dict.get('Functions');
@ -378,11 +379,11 @@ var PDFFunction = (function PDFFunctionClosure() {
var range = dict.getArray('Range');
if (!domain) {
error('No domain.');
throw new FormatError('No domain.');
}
if (!range) {
error('No range.');
throw new FormatError('No range.');
}
var lexer = new PostScriptLexer(fn);
@ -488,19 +489,19 @@ var PostScriptStack = (function PostScriptStackClosure() {
PostScriptStack.prototype = {
push: function PostScriptStack_push(value) {
if (this.stack.length >= MAX_STACK_SIZE) {
error('PostScript function stack overflow.');
throw new Error('PostScript function stack overflow.');
}
this.stack.push(value);
},
pop: function PostScriptStack_pop() {
if (this.stack.length <= 0) {
error('PostScript function stack underflow.');
throw new Error('PostScript function stack underflow.');
}
return this.stack.pop();
},
copy: function PostScriptStack_copy(n) {
if (this.stack.length + n >= MAX_STACK_SIZE) {
error('PostScript function stack overflow.');
throw new Error('PostScript function stack overflow.');
}
var stack = this.stack;
for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
@ -755,8 +756,7 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
}
break;
default:
error('Unknown operator ' + operator);
break;
throw new FormatError(`Unknown operator ${operator}`);
}
}
return stack.stack;