Modified case statement to account for error codes

Case statement will now output different error messages depending on the
error code returned. On returning 0, script should continue, otherwise,
an error message will be printed and the script will be restarted.