handle error cases.