correctly handle errors and send them along with the data