function* gen(x){ try { var y = yield x + 2; } catch (e){ console.log(e); console.log("进入异常catch输出"); } return y; } var g = gen(1); console.log(g.next()); g.throw('出错了');