A Texas judge who shocked a defendant three times with a stun belt to silence him during his own trial violated the man’s constitutional rights, an appeals court has ruled.

“Never before have we seen any behavior like this, nor do we hope to ever see such behavior again,” wrote Justice Yvonne T. Rodriguez, of the Texas Eighth Court of Appeals in El Paso.

The court overturned the man’s conviction last month, admonishing Tarrant County District Court Judge George Gallagher in the 42-page ruling. (The opinion was handed down on Feb. 28 and first reported on Tuesday by Texas Lawyer.)

Though the ruling shows that defendants in Texas are sometimes strapped with stun belts, they are intended for use only if a suspect becomes violent or tries to escape—not to intimidate them, according to the opinion handed down by Rodriguez.

The stun belts deliver a 50,000-volt shock, which can cause seizures, heart problems, or worse, the ruling noted. In rare cases, defendants or law enforcement trainees have died after being shocked by Tasers or stun belts. More often, such shocks can cause the wearer to urinate or defecate on themselves—or to have severe anxiety.

Rodriguez said the justices found that Gallagher ordered the shocks “not for security purposes, but solely as a show of the court’s power as the defendant asked the court to stop ‘torturing’ him.”

She added: “We harbor grave doubts as to whether Morris’ trial comported with basic constitutional mandates.”

During the 2014 trial, Terry Lee Morris was convicted on one count of soliciting the sexual performance of a child online and through text exchanges with a 15-year-old girl. He was sentenced to 60 years in prison.

Things went downhill at the trial as soon as Gallagher asked Morris if he planned to plead guilty or not guilty.

“Sir, before I say that, I have the right to make a defense,” Morris said, noting that he took issue with his defense attorney, Bill Ray, and with the judge. He said that he wanted the judge recused from his case.

Gallagher told Morris to stop his “outbursts.”

“Mr. Morris, I am giving you one warning,” Gallagher said. “You will not make any additional outbursts like that, because two things will happen. Number one, I will either remove you from the courtroom or I will use the shock belt on you.”

“All right, sir,” Morris responded.

“Now, are you going to follow the rules?” the judge asked.

“Sir, I’ve asked you to recuse yourself,” replied Morris.

Gallagher repeated: “Are you going to follow the rules?”

“I have a lawsuit pending against you,” said Morris.

“Hit him,” Gallagher ordered the bailiff, who ostensibly complied. “Are you going to behave?”

Morris tried to explain that he has a history of mental illness, but Gallagher apparently considered it another outburst.

“Hit him again,” the judge ordered. The deputy complied.

After he was shocked a second time, Morris said: “I have a history of mental illness. You’re wrong for doing this.”

“Are you going to behave?” repeated Gallagher.

“You’re torturing a (mental clinic) patient. I have agoraphobia. I’m under medication,” protested Morris.

After another back-and-forth, the judge ordered his bailiff to shock Morris again. He complied.

Morris’s defense attorney told Texas Lawyer he didn’t object to the shocks during the trial because Morris had been acting like “like a loaded cannon ready to go off.”

He reportedly told the site that he did not believe the shocks were real.

(Morris said multiple times in court that he did not wish to be represented by Ray, according to the ruling.)

Morris was removed from the courtroom, and he refused to return for the rest of his trial and almost all of his sentencing hearing, the Washington Post reported. Rodriguez’s opinion founded that the shocks—and the likely resulting anxiety—prevented Morris from attending his own trial, violating the Constitution’s Sixth Amendment. (The judge did not respond to requests for comment from the Post, citing judicial ethics rules.)

“A stun belt is a device meant to ensure physical safety; it is not an operant conditioning collar meant to punish a defendant until he obeys a judge’s whim,” Rodriguez wrote in the opinion.

“As the circumstances of this case perfectly illustrate, the potential for abuse in the absence of an explicit prohibition on non-security use of stun belts exists and must be deterred. We must speak out against it, lest we allow practices like these to affront the very dignity of the proceedings we seek to protect and lead our courts to drift from justice into barbarism,” she said.