mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-23 06:30:04 +00:00
More error handing improvements
This commit is contained in:
parent
481dcfd064
commit
5d9c97d676
@ -61,9 +61,7 @@ void Device::SetProtected(bool write_protected)
|
||||
void Device::SetVendor(const string& vendor)
|
||||
{
|
||||
if (vendor.empty() || vendor.length() > 8) {
|
||||
ostringstream error;
|
||||
error << "Vendor '" << vendor << "' must be between 1 and 8 characters";
|
||||
throw illegal_argument_exception(error.str());
|
||||
throw illegal_argument_exception("Vendor '" + vendor + "' must be between 1 and 8 characters");
|
||||
}
|
||||
|
||||
this->vendor = vendor;
|
||||
@ -77,9 +75,7 @@ void Device::SetProduct(const string& product, bool force)
|
||||
}
|
||||
|
||||
if (product.empty() || product.length() > 16) {
|
||||
ostringstream error;
|
||||
error << "Product '" << product << "' must be between 1 and 16 characters";
|
||||
throw illegal_argument_exception(error.str());
|
||||
throw illegal_argument_exception("Product '" + product + "' must be between 1 and 16 characters");
|
||||
}
|
||||
|
||||
this->product = product;
|
||||
@ -88,9 +84,7 @@ void Device::SetProduct(const string& product, bool force)
|
||||
void Device::SetRevision(const string& revision)
|
||||
{
|
||||
if (revision.empty() || revision.length() > 4) {
|
||||
ostringstream error;
|
||||
error << "Revision '" << revision << "' must be between 1 and 4 characters";
|
||||
throw illegal_argument_exception(error.str());
|
||||
throw illegal_argument_exception("Revision '" + revision + "' must be between 1 and 4 characters");
|
||||
}
|
||||
|
||||
this->revision = revision;
|
||||
|
@ -706,19 +706,25 @@ bool ProcessCmd(int fd, const PbDeviceDefinition& pbDevice, const PbOperation op
|
||||
|
||||
device->SetId(id);
|
||||
device->SetLun(unit);
|
||||
if (!pbDevice.vendor().empty()) {
|
||||
device->SetVendor(pbDevice.vendor());
|
||||
}
|
||||
if (!pbDevice.product().empty()) {
|
||||
device->SetProduct(pbDevice.product());
|
||||
}
|
||||
if (!pbDevice.revision().empty()) {
|
||||
device->SetRevision(pbDevice.revision());
|
||||
}
|
||||
if (!device->IsReadOnly()) {
|
||||
device->SetProtected(pbDevice.protected_());
|
||||
}
|
||||
|
||||
try {
|
||||
if (!pbDevice.vendor().empty()) {
|
||||
device->SetVendor(pbDevice.vendor());
|
||||
}
|
||||
if (!pbDevice.product().empty()) {
|
||||
device->SetProduct(pbDevice.product());
|
||||
}
|
||||
if (!pbDevice.revision().empty()) {
|
||||
device->SetRevision(pbDevice.revision());
|
||||
}
|
||||
}
|
||||
catch(const illegal_argument_exception& e) {
|
||||
return ReturnStatus(fd, false, e.getmsg());
|
||||
}
|
||||
|
||||
if (pbDevice.block_size()) {
|
||||
Disk *disk = dynamic_cast<Disk *>(device);
|
||||
if (disk && disk->IsSectorSizeConfigurable()) {
|
||||
|
Loading…
Reference in New Issue
Block a user