Skip to content

Commit

Permalink
fix: correct exception message on policies comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
fky2015 committed Jul 5, 2023
1 parent 537c0d6 commit f7640ff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Disks/StoragePolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,23 @@ void StoragePolicy::checkCompatibleWith(const StoragePolicyPtr & new_storage_pol
for (const auto & volume : getVolumes())
{
if (!new_volume_names.contains(volume->getName()))
throw Exception(ErrorCodes::BAD_ARGUMENTS, "New storage policy {} shall contain volumes of old one", backQuote(name));
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"New storage policy {} shall contain volumes of old one ({})",
backQuote(new_storage_policy->getName()),
backQuote(name));

std::unordered_set<String> new_disk_names;
for (const auto & disk : new_storage_policy->getVolumeByName(volume->getName())->getDisks())
new_disk_names.insert(disk->getName());

for (const auto & disk : volume->getDisks())
if (!new_disk_names.contains(disk->getName()))
throw Exception(ErrorCodes::BAD_ARGUMENTS, "New storage policy {} shall contain disks of old one", backQuote(name));
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"New storage policy {} shall contain disks of old one ({})",
backQuote(new_storage_policy->getName()),
backQuote(name));
}
}

Expand Down

0 comments on commit f7640ff

Please sign in to comment.