Emit events for error and success

Fixes #19