Fixed error hook emitting