Get at their why
In the heat of the moment, when your emotions are making your decisions for you, you might say something like: “Why would you say that??” or “What were you thinking??” or some version of “WTF?”
Perfectly legitimate questions, but stepping back, you should ask yourself how that framing might affect the other person.
Would it send them to silence or violence, taking them out of dialogue?
You also could send the other person to silence or violence if you say something like “It seems like you’re upset.” Naming others' emotions can backfire.
Here’s a better framing…
“It seems like there’s a reason you’re saying that.”
Then be quiet and listen.
When delivered genuinely, it sends the message you’re interested, maybe even concerned, about what’s going on for them, rather than accusing them of wrong-headed thinking or trying to control their emotions.