If the proceedings are dismissed for insufficiency, want of prosecution, or the election is by the court confirmed, judgment shall be rendered against the party contesting such election for costs, in favor of the party charged with error or omission.
If such election is annulled and set aside, judgment for costs shall be rendered against the party charged with the error or omission and in favor of the party alleging the same.