Trap errors in get_selected_line