@gremlins @darkuncle @b0rk orrr, if you are using an actual posix shell…

(expression) || (echo 'error: thingy happened wrong'; break)

will solve most of these 'issues'.
except unset variables. You should always set any variables you plan to use or check for their existance at the start of a script anyway, especially if you ever used csh you know why.