Handle error event