Try block for to_dict