mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Syntax changed that will help minifiers/compilers (such as the Closure Compiler) in their processing. In particular, preventing said minifiers/compilers from making dangerous renames.
This commit is contained in:
parent
438e3c8f6d
commit
0fbbc5a840
5 changed files with 40 additions and 19 deletions
27
src/util.js
27
src/util.js
|
@ -5,12 +5,16 @@
|
|||
|
||||
// Use only for debugging purposes. This should not be used in any code that is
|
||||
// in mozilla master.
|
||||
function log(msg) {
|
||||
if (console && console.log)
|
||||
console.log(msg);
|
||||
else if (print)
|
||||
print(msg);
|
||||
}
|
||||
var log = (function() {
|
||||
if ('console' in globalScope && 'log' in globalScope['console']) {
|
||||
return globalScope['console']['log'].bind(globalScope['console']);
|
||||
} else if ('print' in globalScope) {
|
||||
return globalScope['print'].bind(globalScope);
|
||||
} else {
|
||||
return function nop() {
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
// A notice for devs that will not trigger the fallback UI. These are good
|
||||
// for things that are helpful to devs, such as warning that Workers were
|
||||
|
@ -33,7 +37,16 @@ function warn(msg) {
|
|||
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||
// throwing an exception.
|
||||
function error(msg) {
|
||||
log('Error: ' + msg);
|
||||
// If multiple arguments were passed, pass them all to the log function.
|
||||
if (arguments.length > 1) {
|
||||
var logArguments = ['Error:'];
|
||||
logArguments.push.apply(logArguments, arguments);
|
||||
log.apply(null, logArguments);
|
||||
// Join the arguments into a single string for the lines below.
|
||||
msg = [].join.call(arguments, ' ');
|
||||
} else {
|
||||
log('Error: ' + msg);
|
||||
}
|
||||
log(backtrace());
|
||||
PDFJS.LogManager.notify('error', msg);
|
||||
throw new Error(msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue