emit  event if the function throws