The contestant and the defendant shall be liable to the officers and witnesses for the costs made by them, respectively. If the result of the primary or election is confirmed, the petition dismissed, or the prosecution fails, judgment shall be rendered against the contestant for costs; and, if the judgment is against the defendant or the result of the primary or election is set aside, he or she shall pay the costs at the discretion of the court. After entry of judgment, the costs may be collected by attachment or otherwise.
OCGA § 21-2-529