Browse Source

Merge pull request #2570 from mduan/issue2556

Fix bug w/ exception not being passed to error callbacks of a Promise
Brendan Dahl 12 years ago
parent
commit
a0313bef22
  1. 5
      src/util.js

5
src/util.js

@ -503,6 +503,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() { @@ -503,6 +503,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
this.name = name;
this.isRejected = false;
this.error = null;
this.exception = null;
// If you build a promise and pass in some data it's already resolved.
if (data != null) {
this.isResolved = true;
@ -611,6 +612,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() { @@ -611,6 +612,7 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
this.isRejected = true;
this.error = reason || null;
this.exception = exception || null;
var errbacks = this.errbacks;
for (var i = 0, ii = errbacks.length; i < ii; i++) {
@ -629,7 +631,8 @@ var Promise = PDFJS.Promise = (function PromiseClosure() { @@ -629,7 +631,8 @@ var Promise = PDFJS.Promise = (function PromiseClosure() {
callback.call(null, data);
} else if (this.isRejected && errback) {
var error = this.error;
errback.call(null, error);
var exception = this.exception;
errback.call(null, error, exception);
} else {
this.callbacks.push(callback);
if (errback)

Loading…
Cancel
Save