mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Merge pull request #2058 from Pimm/master
Small fixes for normal and potential post-compilation bugs
This commit is contained in:
commit
75e928c102
9 changed files with 53 additions and 29 deletions
27
src/util.js
27
src/util.js
|
@ -19,12 +19,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
|
||||
|
@ -47,7 +51,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