Permalink
Browse files

document deref, fix bug where errors were not

captured.
  • Loading branch information...
David Nolen
David Nolen committed May 1, 2010
1 parent b8f8ec3 commit 05cf01ed3900d96c9f1c0f760d1b847f398ffbfa
Showing with 6 additions and 1 deletion.
  1. +6 −1 Promises.js
View
@@ -139,7 +139,7 @@ var Promise = new Class({
req.addEvent('onSuccess', function(r) {
var json = ($type(r) == 'object') ? r : ((!req.options.bare) ? JSON.decode(r) : r),
v;
- if(Promise.deref !== null && req.options.bare !== true) {
+ if(Promise.deref !== null && req.options.bare !== true && !json.error) {
var temp = $get.apply(null, [json].concat(Promise.deref.split(".")));
if(temp !== null && temp !== undefined) {
v = temp;
@@ -370,6 +370,11 @@ var Promise = new Class({
return fn(this.value());
}
});
+
+/*
+ Variable: Promise.deref
+ Setting for how Promises will be dereferenced.
+*/
Promise.deref = 'data';
/*

0 comments on commit 05cf01e

Please sign in to comment.