A dog that inflicts an injury upon a person shall be exempt from the meaning of a dangerous or vicious dog as defined in this chapter in the following instances: (1) A law enforcement officer carrying out the law enforcement officer's official duties; or (2) A dog used for agricultural purposes while herding livestock; or (3) If the injury inflicted by the dog was sustained by a person who, at the time, was committing a willful trespass or other tort or was tormenting, abusing, or assaulting the dog or had in the past been observed or reported to have tormented, abused, or assaulted the dog or was committing or attempting to commit a crime; or (4) If the injury inflicted by the dog was sustained by a domestic animal or livestock which was trespassing on the property of the dog's owner or the property of person who was in control of the dog.