This commit is mainly just ripping out these 6 lines into a separate function (`get_case_errors`) and then calling it here and below.