You should check your generator function. There's too few context to assertive recognize your problem with Exception/Error Handling... however, I've identified a behavior with try/catch:
*Tested on Firefox 33.1.1 and Chrome 39.0.2171.65 m
This is the WRONG way to declare a generator function (without *), and it seems it affects the Error Handling behavior:
function wrongGenerator()
{
for(var i = 0; i <= 0 ; i++)
{
if(i < 3)
yield i;
}
}
try
{
var gen = new wrongGenerator();
gen.next();
gen.next();
gen.next();
gen.next();
throw new Error("Test");
}
catch(e)
{
//This should return an Error Object, but it just don't.
console.log(e);
console.log(e instanceof Error);
}
On the other hand, when you declare a generator function the right way, error handling works just nicely:
function* rightGenerator() {
for(var i = 0; i <= 1; i++)
{
if(i < 3)
var a = yield i;
}
}
try
{
var gen = new rightGenerator();
gen.next();
gen.next();
gen.next();
gen.next();
throw new Error("Test");
}
catch(e)
{
//Returns an Error Object, as expected.
console.log(e);
console.log(e instanceof Error);
}
Not sure if this is an issue on Node environment, but I think it could answer partially your concern.