Fix Error handling for generator

A generator raising an exception will now correctly emit an `error` event.
This can be used in unit test as the error event is now binded between the generator and its run context. 
assign value to `this` rather than scoped variable. Pretty minor, but that's how we do it in the yeoman codebase. The reason is simply to make sure they're not leaked in-between tests.