error handling on emit