Start a pane with a command, like tmux split-window 'make test', and the pane disappears the moment the command ends. If it failed, the error leaves with it.
The remain-on-exit option keeps the dead pane on screen. My favourite value only does that when something went wrong:
set -g remain-on-exit failed
A command that exits with status 0 closes its pane as usual. One that fails leaves the pane in place, with the output still readable and a line at the bottom saying which status it exited with. Use on instead of failed if you want to keep every pane.
From there you have two options. Ctrl-b x closes the dead pane, or you run the command again in the same spot:
tmux respawn-pane
The failed value needs tmux 3.2 or later. Newer versions also have key and failed-key, which close the pane on the next keypress, and remain-on-exit-format to change the text on that last line.
Dead panes pile up quietly if you use on for everything, so I’d keep that value for windows where you really want to read every result.
Further reading: tmux manual page (OpenBSD)