In the legal drama film "Roman J. Israel, Esq.", the protagonist attorney is fined $5,000 for court contempt because, during a preliminary hearing, he claimed that the civil rights of his client had been violated and he continued to pursue that after the judges told him that he can address that at trial. Part of the scene is even in the movie trailer.
The transcript is the following:
Roman: Objection. Motion to strike. Mr. Ramirez was told he was not under arrest and was interrogated without his Miranda warning, yet he was refused use of the bathroom. That is a violation of civil rights.
Judge: Overruled.
Roman: If a cop hauls you in and says you can't use the bathroom, then you're being detained...
Judge: We are moving on...
Roman: What was he supposed to do, pee himself?
Judge: You can address this at trial.
Roman: I would like to address it now. I'm just saying we have a real...
Judge: Mr. Israel. Did you hear what I said?
Roman: If armed guards in this courtroom detained you and would not allow you to use the bathroom you would be detained. What is good for the goose is good for the gander.
Judge: I'm gonna hold you in contempt if you pursue this.
Roman: With respect, you're asking me to obey an erroneous court decision.
Judge: Find you in contempt.
Is this legal? And if so, would such decision make sense or would actually be easily overturned in appeal/cause problems to the judge/court... in other words, something a real judge would not do.