If a sheriff or other officer is compelled to pay a judgment or a part thereof by reason of a default of such officer, except for failing to pay over any money collected or for wasting property levied on, the sheriff or other officer may have execution therefor against the principal defendant in such judgment as provided in the case of a surety.