Fixed error event emitting