Repository: canjs/can-zone (js)

Issue:
Can-zone tasks.js should reject the promise instead of rethrowing the error.
This is to keep the caught promises errors from showing up in the console.  This code is currently rethrowing the error, when it could pass on a rejected promise: https://github.com/canjs/can-zone/blob/master/lib/tasks.js#L109

https://github.com/donejs/bitcentive/issues/112

Pull request description:
Don't rethrow in a Promise rejection
Instead of rethrowing in a promise rejection, which forces the rejection
into an Error object, simply return a new Promise.reject(val).

Closes #92

Patch:
diff --git a/lib/tasks.js b/lib/tasks.js
index 3c58892..38fabd9 100644
--- a/lib/tasks.js
+++ b/lib/tasks.js
@@ -106,8 +106,7 @@ exports.then = function(then){
 			if(fn) {
 				return fn.apply(this, arguments);
 			} else if(rejected) {
-				val = typeof val === "string" ? new Error(val) : val;
-				throw val;
+				return Promise.reject(val);
 			}
 			return val;
 		}, false);


Test patch:
diff --git a/test/test.js b/test/test.js
index 2e1baea..db4dfd3 100644
--- a/test/test.js
+++ b/test/test.js
@@ -597,7 +597,7 @@ describe("Promises", function(){
 		new Zone().run(function(){
 
 			Promise.reject("uh oh").then().then(null, function(err){
-				Zone.current.data.reason = err.message;
+				Zone.current.data.reason = err;
 			});
 
 		}).then(function(data){