throw a generic message upon error

hi all,
in ksh, is there a way to throw a generic error message. i have lots of commands in my script and i didnt want to put

if [ $? -eq 0 ] ; then
doStuff();
else
print "an error occured, please run script again";
fi

around all the commands used. is there a way detect a command has failed and to make it throw the above error message ??

thanks in advance.

Maybe something like this using brackets to group commands together...

{ command1 && dostuff; } || print "err message"

If command1 is successful, then run the 'dostuff' function, if not successful, print error message.

if you're calling a function though, you don't need the parentheses, as in "dostuff()", it would just be "dostuff". You can use the parentheses when you're defining a function though.