swremove unsuccessful case handling

i am using the command "swremove productname".... How can i check the unsucceful condition?.... i want to say "if unsuccessful display that message to the user and exit"....

Can anu one help me??.... i am coding in this script for the first time so please dont mind...

THanks

Assuming swremove correctly sets its exit code on failure,

if swremove productname; then
  : success
else
  echo oh no, exit code $?
fi