(a) No dog may be declared dangerous or vicious if any injury or damage is sustained by a person who, at the time the injury or damage was sustained, was committing a willful trespass or other tort upon premises occupied by the owner or keeper of the dog, or was teasing, tormenting, abusing, or assaulting the dog or has, in the past, been observed or reported to have tormented, abused or assaulted the dog, or was committing or attempting to commit a crime. No dog may be declared dangerous or vicious if the dog was protecting or defending a person within the immediate vicinity of the dog from an unjustified attack or assault. No dog may be declared potentially dangerous or vicious if an injury or damage was sustained by a domestic animal which at the time the injury or damage was sustained was teasing, tormenting, abusing, or assaulting the dog.
(b) No dog may be declared dangerous or vicious if the injury or damage to a domestic animal was sustained while the dog was working as a hunting dog, herding dog, or predator control dog on the property of, or under the control of, its owner or keeper, and the damage or injury was to a species or type of domestic animal appropriate to the work of the dog.