(CNN) A small-town Pennsylvania police officer will not face charges after shooting an unarmed man during a struggle because the officer honestly believed at the time he was using his Taser, not his service weapon, the Bucks County district attorney's office says in a statement.

District Attorney Matthew Weintraub said the March 3 shooting was "was neither justified, nor criminal, but was excused," according to the statement posted on the DA's office website

"Weintraub said the law excuses the shooting officer's conduct from criminal prosecution because of his 'honest but mistaken' belief he was deploying his Taser at the time he discharged his service weapon," the statement said.

The wounded man, Brian Riling, was hospitalized in critical condition for several days after being shot in the stomach but has since been released, the statement said.

The New Hope officer, who was not identified because he wasn't charged, was placed on paid administrative leave and retired from the department April 10, the statement said.

The investigation conducted by detectives employed by the DA's office was partly based on a video shot inside a holding cell in the police station in New Hope, a town of 2,500 people about 40 miles north of Philadelphia. The statement refers several times to a letter Weintraub sent to the New Hope police chief, but the DA's office won't release that letter, said James O'Malley, the communications director for the DA's office.

CNN reached out to Riling's lawyer and has yet to receive a response. CNN also tried to contact Weintraub and the New Hope police chief, Michael Cummings, but did not receive a response.

Struggle inside a holding cell

Riling was in police custody after being charged March 3 with intimidation and retaliation against a victim, simple assault and related offenses stemming from an incident on the same day, the district attorney's statement said. He was also charged with burglarizing the same victim's home in mid-February, the statement said.

The video shows Riling removing his belt inside the cell at an officer's direction when a white, rectangular object falls from his pants to the floor. Riling puts his foot on the object. The DA's statement said the object was "consistent with a drug baggie."

The video shows the officer pushing Riling onto a concrete bench but Riling resists and the men struggle. The DA's statement said Riling threw the object into the toilet, but the toilet is not visible in the video.

A second officer comes into the cell to help the first officer. While holding his service weapon in his right hand, the second officer yells "Taser" and shoots Riling in the stomach, the video shows. The two officers leave the cell for a moment. The DA's statement says Riling flushes the toilet during this time, but the toilet can't be seen.

The first officer comes back into the cell and at first orders Riling to get onto the seat. But Riling lies on the floor, saying, "I don't want to die, dude," and "Why'd you shoot me? Are you kidding me?" Later he asks, "What the [expletive] is wrong with that guy?"

'He did not possess the criminal mental state'

The DA's statement discusses the officer's "mindset" during the incident.

The officer who shot Riling was aware of Riling's "criminal episodes" before the shooting and heard Riling make violent threats during a phone call with the "previously mentioned victim," the statement said.

"Given the totality of circumstances, the officer would have been justified in using his Taser to regain control of Riling inside the holding cell, DA Weintraub said in his letter [to the police chief], as the officer had a reasonable belief the scuffle posed a danger to his fellow officer," the statement said.

"The use of a firearm must be an officer's last resort, Weintraub wrote, and was not justified in this case. However, the letter [to the police chief] continues, because the officer believed he was deploying his Taser and not wielding his service firearm, he did not possess the criminal mental state required to be guilty of a crime under state law."

The statement mentions a section of the Pennsylvania Crimes Code which says a person has a defense to a criminal charge if he makes a mistake for which there is "a reasonable explanation or excuse."

The DA's statement says the officer violated a department policy by wearing the Taser on his right side, in front of his firearm, instead of on the . "non-dominant side, in what is known as a cross-draw position."

That policy violation didn't constitute a violation of law, though, the statement concludes.

"Weintraub also considered the officer's decades of exemplary service to the citizens of New Hope as evidenced by dozens of commendations and letters, as compared to relatively few minor historical infractions on his service record," the statement said.

The New Hope Police Department posted this statement on its website : "The Department thanks District Attorney Weintraub and the members of his office for their thorough investigation and report. The police department has no further information to release, and no further comment on this matter."

Previous cases

This is not the first time an officer has shot a suspect with a gun, thinking he was using a Taser.

Robert Bates, a reserve deputy with the Tulsa County Sheriff's Office in Oklahoma, said he meant to use his Taser stun gun, not his revolver, on suspect Eric Courtney Harris, who had been tackled by other deputies and was being held on the ground on April 2, 2015.

In a 2009 case, a Bay Area Rapid Transit police officer fired his gun instead of his Taser, killing 22-year-old Oscar Grant in Oakland, California.