trapping errors

I am using unixs script to submit programs (SQRS) and need to trap any time of error that is received once the job finishes.

Examples of the type of errors I am getting

Error! SQR Failed To Process
mkdir: Failed to make directory

These are showing up in a log file but I do not want to have to grep on the log file for every possible text string.

I am new to unix , although I have had exposure in the pass to it. Would welcome direction and help in how to code for errors.

I meant any type of error in my message.

You need to be more specific about what you're doing, please.

Okay, I want to trap any system error messages that may occur within a unix shell script. When I do a mkdir command and it fails how to trap the error.
When my sqr program fails with "Error! SQR Failed To Process" how to trap the error and exit the shell script with an exit 99