Listen to error event