Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug w/ exception not being passed to error callbacks of a Promise #2570

Merged
merged 1 commit into from
Jan 22, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand All @@ -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)
Expand Down