handle response in case of error