handle error event when data is undefined