Update error handling

This commit is contained in:
Uwe Seimet 2023-11-14 10:06:42 +01:00
parent 06ab3faa33
commit a338cf3f64

View File

@ -70,7 +70,7 @@ int ScsiCtl::run(const vector<char *>& args) const
PbCommand command; PbCommand command;
PbDeviceDefinition* device = command.add_devices(); PbDeviceDefinition* device = command.add_devices();
device->set_id(-1); device->set_id(-1);
const char *hostname = "localhost"; string hostname = "localhost";
int port = 6868; int port = 6868;
string param; string param;
string log_level; string log_level;
@ -129,8 +129,12 @@ int ScsiCtl::run(const vector<char *>& args) const
break; break;
case 'E': case 'E':
command.set_operation(IMAGE_FILE_INFO);
filename = optarg; filename = optarg;
if (filename.empty()) {
cerr << "Error: Missing filename" << endl;
exit(EXIT_FAILURE);
}
command.set_operation(IMAGE_FILE_INFO);
break; break;
case 'e': case 'e':
@ -151,15 +155,27 @@ int ScsiCtl::run(const vector<char *>& args) const
case 'h': case 'h':
hostname = optarg; hostname = optarg;
if (hostname.empty()) {
cerr << "Error: Missing hostname" << endl;
exit(EXIT_FAILURE);
}
break; break;
case 'J': case 'J':
filename = optarg; filename = optarg;
if (filename.empty()) {
cerr << "Error: Missing filename" << endl;
exit(EXIT_FAILURE);
}
to_json = true; to_json = true;
break; break;
case 'B': case 'B':
filename = optarg; filename = optarg;
if (filename.empty()) {
cerr << "Error: Missing filename" << endl;
exit(EXIT_FAILURE);
}
to_binary = true; to_binary = true;
break; break;