Throw proper exception if system command failed.