WICHITA, Kan. (AP) — A former Wichita police officer who wounded a 9-year-old girl when he fired at her family's dog is immune from criminal prosecution and can't be sued, a judge ruled.

Judge Kevin O’Connor issued his ruling last month in Dexter Betts's case, although it wasn't available in public court records until Friday. The Sedgwick County district attorney’s office filed a notice of appeal, The Wichita Eagle reported.

Betts had been charged with aggravated battery in the Dec. 30, 2017, shooting in which a bullet fragment ricocheted off the floor and hit the girl. Officers went to the family's home when the girl's mother reported her husband was threatening to hurt himself.

The family's attorney says the dog only went up to the officer and barked. The girl and dog were not seriously injured.

Betts’s lawyer asked the judge to dismiss the case, arguing that he had legally fired his weapon in self-defense and was entitled to immunity.

Prosecutors wrote in court filings that it was ''not reasonable under the circumstances to fire twice without a clear background, with a child in the line of fire, a few feet away, at a dog the officer already knew was present.''

The Kansas criminal liability laws state that a person is immune if the use of force is determined to be justified.

O’Connor wrote that the girl's injuries were ‘’certainly unfortunate and regrettable," but that prosecutors had failed to show that Betts' use of force wasn't justified.