mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Removes error()
This commit is contained in:
parent
ac9802809c
commit
d028c26210
24 changed files with 318 additions and 260 deletions
|
@ -288,27 +288,13 @@ function deprecated(details) {
|
|||
console.log('Deprecated API usage: ' + details);
|
||||
}
|
||||
|
||||
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||
// throwing an exception.
|
||||
function error(msg) {
|
||||
if (verbosity >= VERBOSITY_LEVELS.errors) {
|
||||
console.log('Error: ' + msg);
|
||||
console.log(backtrace());
|
||||
}
|
||||
function unreachable(msg) {
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
function backtrace() {
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (e) {
|
||||
return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
|
||||
}
|
||||
}
|
||||
|
||||
function assert(cond, msg) {
|
||||
if (!cond) {
|
||||
error(msg);
|
||||
unreachable(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,6 +485,21 @@ var XRefParseException = (function XRefParseExceptionClosure() {
|
|||
return XRefParseException;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Error caused during parsing PDF data.
|
||||
*/
|
||||
let FormatError = (function FormatErrorClosure() {
|
||||
function FormatError(msg) {
|
||||
this.message = msg;
|
||||
}
|
||||
|
||||
FormatError.prototype = new Error();
|
||||
FormatError.prototype.name = 'FormatError';
|
||||
FormatError.constructor = FormatError;
|
||||
|
||||
return FormatError;
|
||||
})();
|
||||
|
||||
var NullCharactersRegExp = /\x00/g;
|
||||
|
||||
function removeNullCharacters(str) {
|
||||
|
@ -1266,7 +1267,7 @@ function MessageHandler(sourceName, targetName, comObj) {
|
|||
callback.resolve(data.data);
|
||||
}
|
||||
} else {
|
||||
error('Cannot resolve callback ' + callbackId);
|
||||
throw new Error(`Cannot resolve callback ${callbackId}`);
|
||||
}
|
||||
} else if (data.action in ah) {
|
||||
let action = ah[data.action];
|
||||
|
@ -1302,7 +1303,7 @@ function MessageHandler(sourceName, targetName, comObj) {
|
|||
action[0].call(action[1], data.data);
|
||||
}
|
||||
} else {
|
||||
error('Unknown action from worker: ' + data.action);
|
||||
throw new Error(`Unknown action from worker: ${data.action}`);
|
||||
}
|
||||
};
|
||||
comObj.addEventListener('message', this._onComObjOnMessage);
|
||||
|
@ -1312,7 +1313,7 @@ MessageHandler.prototype = {
|
|||
on(actionName, handler, scope) {
|
||||
var ah = this.actionHandler;
|
||||
if (ah[actionName]) {
|
||||
error('There is already an actionName called "' + actionName + '"');
|
||||
throw new Error(`There is already an actionName called "${actionName}"`);
|
||||
}
|
||||
ah[actionName] = [handler, scope];
|
||||
},
|
||||
|
@ -1633,6 +1634,7 @@ export {
|
|||
UnknownErrorException,
|
||||
Util,
|
||||
XRefParseException,
|
||||
FormatError,
|
||||
arrayByteLength,
|
||||
arraysToBytes,
|
||||
assert,
|
||||
|
@ -1641,7 +1643,6 @@ export {
|
|||
createPromiseCapability,
|
||||
createObjectURL,
|
||||
deprecated,
|
||||
error,
|
||||
getLookupTableFactory,
|
||||
getVerbosityLevel,
|
||||
globalScope,
|
||||
|
@ -1674,4 +1675,5 @@ export {
|
|||
stringToUTF8String,
|
||||
utf8StringToString,
|
||||
warn,
|
||||
unreachable,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue