fail_if_cmd_error [fix]

the last command's exit-code have to be catched before the err_msg variable initialization, because that will generate a new exit-code!!