Index: src/promise.js |
diff --git a/src/promise.js b/src/promise.js |
index 8e22c315a3b140bd27afbefbb23bbca775f7e69a..f700be909264cee92f077d60c5f331613ae86aed 100644 |
--- a/src/promise.js |
+++ b/src/promise.js |
@@ -227,7 +227,15 @@ PromiseCoerce.table = new $WeakMap; |
function PromiseCoerce(constructor, x) { |
if (!IsPromise(x) && IS_SPEC_OBJECT(x)) { |
- var then = x.then; |
+ var then; |
+ try { |
+ then = x.then; |
+ } catch(e) { |
+ var deferred = %_CallFunction(constructor, PromiseDeferred); |
+ PromiseCoerce.table.set(x, deferred.promise); |
+ deferred.reject(e); |
+ return deferred.promise; |
+ } |
if (typeof then === 'function') { |
if (PromiseCoerce.table.has(x)) { |
return PromiseCoerce.table.get(x); |