Commit 47b35e23 authored by Stefan Penner's avatar Stefan Penner

simplify handling the thenable.

Removed the double try/catch
parent 253666b1
...@@ -131,16 +131,11 @@ function resolve(promise, value) { ...@@ -131,16 +131,11 @@ function resolve(promise, value) {
function handleThenable(promise, value) { function handleThenable(promise, value) {
var then = null; var then = null;
if (objectOrFunction(value)) { try {
try { if (objectOrFunction(value)) {
then = value.then; then = value.then;
} catch(e) {
reject(promise, e);
return true;
}
if (isFunction(then)) { if (isFunction(then)) {
try {
then.call(value, function(val) { then.call(value, function(val) {
if (value !== val) { if (value !== val) {
resolve(promise, val); resolve(promise, val);
...@@ -150,11 +145,13 @@ function handleThenable(promise, value) { ...@@ -150,11 +145,13 @@ function handleThenable(promise, value) {
}, function(val) { }, function(val) {
reject(promise, val); reject(promise, val);
}); });
} catch (e) {
reject(promise, e); return true;
} }
return true;
} }
} catch (error) {
reject(promise, error);
return true;
} }
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment