A dog that inflicts an injury upon a person when the dog is being used by a law enforcement officer to carry out the law enforcement officer's official duties shall not be a dangerous dog or potentially dangerous dog within the meaning of this article. A dog shall not be a dangerous dog or potentially dangerous dog within the meaning of this article if the injury inflicted by the dog was sustained by a person who at the time was committing a willful trespass or other tort, was tormenting, abusing, or assaulting the dog, had in the past been reported to have tormented, abused, or assaulted the dog, or was committing or attempting to commit a crime.