Fix error handling in get_header_and_data.