how to make some condition when program/tool unsuccesfully ends with error..

Simply, when i have tool "pdftotext", "sed" or "wget" and if this tool make an error in converting or downloading or something, I want to terminate my script...something like:

if [ pdftotext throws error/exception ]; then
exit 1
fi

bud I dont know how..can you help guys?:confused:

pdftotext <arg..>

if [ $? -eq 0 ]; then
  echo "Success"
else
  echo "Failed"
  exit 1
fi

what does [ $? -eq 0 ] means

//ah i've already noticed the $? is number of errors occured.

thanks

Have a read of this: Exit and Exit Status