mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Merge pull request #9272 from nveenjain/fix/8846
Replaced occurence of `throw new Error` with `unreachable`
This commit is contained in:
commit
6bbe91079b
12 changed files with 41 additions and 32 deletions
|
@ -14,7 +14,8 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
CMapCompressionType, FormatError, isString, MissingDataException, Util, warn
|
||||
CMapCompressionType, FormatError, isString, MissingDataException,
|
||||
unreachable, Util, warn
|
||||
} from '../shared/util';
|
||||
import { isCmd, isEOF, isName, isStream } from './primitives';
|
||||
import { Lexer } from './parser';
|
||||
|
@ -353,19 +354,19 @@ var IdentityCMap = (function IdentityCMapClosure() {
|
|||
addCodespaceRange: CMap.prototype.addCodespaceRange,
|
||||
|
||||
mapCidRange(low, high, dstLow) {
|
||||
throw new Error('should not call mapCidRange');
|
||||
unreachable('should not call mapCidRange');
|
||||
},
|
||||
|
||||
mapBfRange(low, high, dstLow) {
|
||||
throw new Error('should not call mapBfRange');
|
||||
unreachable('should not call mapBfRange');
|
||||
},
|
||||
|
||||
mapBfRangeToArray(low, high, array) {
|
||||
throw new Error('should not call mapBfRangeToArray');
|
||||
unreachable('should not call mapBfRangeToArray');
|
||||
},
|
||||
|
||||
mapOne(src, dst) {
|
||||
throw new Error('should not call mapCidOne');
|
||||
unreachable('should not call mapCidOne');
|
||||
},
|
||||
|
||||
lookup(code) {
|
||||
|
@ -402,7 +403,7 @@ var IdentityCMap = (function IdentityCMapClosure() {
|
|||
},
|
||||
|
||||
get isIdentityCMap() {
|
||||
throw new Error('should not access .isIdentityCMap');
|
||||
unreachable('should not access .isIdentityCMap');
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FormatError, info, isString, shadow, warn } from '../shared/util';
|
||||
import {
|
||||
FormatError, info, isString, shadow, unreachable, warn
|
||||
} from '../shared/util';
|
||||
import { isDict, isName, isStream } from './primitives';
|
||||
|
||||
var ColorSpace = (function ColorSpaceClosure() {
|
||||
|
@ -54,7 +56,7 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
|
||||
// Constructor should define this.numComps, this.defaultColor, this.name
|
||||
function ColorSpace() {
|
||||
throw new Error('should not call ColorSpace constructor');
|
||||
unreachable('should not call ColorSpace constructor');
|
||||
}
|
||||
|
||||
ColorSpace.prototype = {
|
||||
|
@ -74,7 +76,7 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
*/
|
||||
getRgbItem: function ColorSpace_getRgbItem(src, srcOffset,
|
||||
dest, destOffset) {
|
||||
throw new Error('Should not call ColorSpace.getRgbItem');
|
||||
unreachable('Should not call ColorSpace.getRgbItem');
|
||||
},
|
||||
/**
|
||||
* Converts the specified number of the color values to the RGB colors.
|
||||
|
@ -88,7 +90,7 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count,
|
||||
dest, destOffset, bits,
|
||||
alpha01) {
|
||||
throw new Error('Should not call ColorSpace.getRgbBuffer');
|
||||
unreachable('Should not call ColorSpace.getRgbBuffer');
|
||||
},
|
||||
/**
|
||||
* Determines the number of bytes required to store the result of the
|
||||
|
@ -97,7 +99,7 @@ var ColorSpace = (function ColorSpaceClosure() {
|
|||
*/
|
||||
getOutputLength: function ColorSpace_getOutputLength(inputLength,
|
||||
alpha01) {
|
||||
throw new Error('Should not call ColorSpace.getOutputLength');
|
||||
unreachable('Should not call ColorSpace.getOutputLength');
|
||||
},
|
||||
/**
|
||||
* Returns true if source data will be equal the result/output data.
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { bytesToString, FormatError, Util } from '../shared/util';
|
||||
import {
|
||||
bytesToString, FormatError, unreachable, Util
|
||||
} from '../shared/util';
|
||||
import { CFFParser } from './cff_parser';
|
||||
import { getGlyphsUnicode } from './glyphlist';
|
||||
import { StandardEncoding } from './encodings';
|
||||
|
@ -628,7 +630,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
|
|||
},
|
||||
|
||||
compileGlyphImpl() {
|
||||
throw new Error('Children classes should implement this.');
|
||||
unreachable('Children classes should implement this.');
|
||||
},
|
||||
|
||||
hasBuiltPath(unicode) {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import {
|
||||
bytesToString, FONT_IDENTITY_MATRIX, FontType, FormatError, info, isNum,
|
||||
isSpace, MissingDataException, readUint32, shadow, string32, warn
|
||||
isSpace, MissingDataException, readUint32, shadow, string32, unreachable, warn
|
||||
} from '../shared/util';
|
||||
import {
|
||||
CFF, CFFCharset, CFFCompiler, CFFHeader, CFFIndex, CFFParser, CFFPrivateDict,
|
||||
|
@ -295,7 +295,7 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
|
|||
},
|
||||
|
||||
amend(map) {
|
||||
throw new Error('Should not call amend()');
|
||||
unreachable('Should not call amend()');
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
FormatError, info, isBool, isEvalSupported, shadow
|
||||
FormatError, info, isBool, isEvalSupported, shadow, unreachable
|
||||
} from '../shared/util';
|
||||
import { isDict, isStream } from './primitives';
|
||||
import { PostScriptLexer, PostScriptParser } from './ps_parser';
|
||||
|
@ -822,7 +822,7 @@ var PostScriptCompiler = (function PostScriptCompilerClosure() {
|
|||
this.type = type;
|
||||
}
|
||||
AstNode.prototype.visit = function (visitor) {
|
||||
throw new Error('abstract method');
|
||||
unreachable('abstract method');
|
||||
};
|
||||
|
||||
function AstArgument(index, min, max) {
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
import {
|
||||
bytesToString, createPromiseCapability, createValidAbsoluteUrl, FormatError,
|
||||
info, InvalidPDFException, isBool, isString, MissingDataException, shadow,
|
||||
stringToPDFString, stringToUTF8String, Util, warn, XRefParseException
|
||||
stringToPDFString, stringToUTF8String, unreachable, Util, warn,
|
||||
XRefParseException
|
||||
} from '../shared/util';
|
||||
import {
|
||||
Dict, isCmd, isDict, isName, isRef, isRefsEqual, isStream, Ref, RefSet,
|
||||
|
@ -1474,7 +1475,7 @@ var XRef = (function XRefClosure() {
|
|||
*/
|
||||
var NameOrNumberTree = (function NameOrNumberTreeClosure() {
|
||||
function NameOrNumberTree(root, xref) {
|
||||
throw new Error('Cannot initialize NameOrNumberTree.');
|
||||
unreachable('Cannot initialize NameOrNumberTree.');
|
||||
}
|
||||
|
||||
NameOrNumberTree.prototype = {
|
||||
|
|
|
@ -34,14 +34,14 @@ var ShadingType = {
|
|||
var Pattern = (function PatternClosure() {
|
||||
// Constructor should define this.getPattern
|
||||
function Pattern() {
|
||||
throw new Error('should not call Pattern constructor');
|
||||
unreachable('should not call Pattern constructor');
|
||||
}
|
||||
|
||||
Pattern.prototype = {
|
||||
// Input: current Canvas context
|
||||
// Output: the appropriate fillStyle or strokeStyle
|
||||
getPattern: function Pattern_getPattern(ctx) {
|
||||
throw new Error(`Should not call Pattern.getStyle: ${ctx}`);
|
||||
unreachable(`Should not call Pattern.getStyle: ${ctx}`);
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import {
|
||||
createPromiseCapability, createValidAbsoluteUrl, MissingDataException,
|
||||
NotImplementedException, shadow, Util, warn
|
||||
NotImplementedException, shadow, unreachable, Util, warn
|
||||
} from '../shared/util';
|
||||
import { ChunkedStreamManager } from './chunked_stream';
|
||||
import { PDFDocument } from './document';
|
||||
|
@ -23,7 +23,7 @@ import { Stream } from './stream';
|
|||
|
||||
var BasePdfManager = (function BasePdfManagerClosure() {
|
||||
function BasePdfManager() {
|
||||
throw new Error('Cannot initialize BaseManagerManager');
|
||||
unreachable('Cannot initialize BaseManagerManager');
|
||||
}
|
||||
|
||||
BasePdfManager.prototype = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue