sstables: : remove unnecessary throws
Throws are translated to passing the exceptions directly.
This commit is contained in:
@@ -551,7 +551,7 @@ inline void write(sstable_version_types v, file_writer& out, const summary& s) {
|
||||
future<summary_entry&> sstable::read_summary_entry(size_t i) {
|
||||
// The last one is the boundary marker
|
||||
if (i >= (_components->summary.entries.size())) {
|
||||
throw std::out_of_range(format("Invalid Summary index: {:d}", i));
|
||||
return make_exception_future<summary_entry&>(std::out_of_range(format("Invalid Summary index: {:d}", i)));
|
||||
}
|
||||
|
||||
return make_ready_future<summary_entry&>(_components->summary.entries[i]);
|
||||
@@ -624,7 +624,7 @@ future<> parse(const schema& s, sstable_version_types v, random_access_reader& i
|
||||
uint32_t length = *len;
|
||||
|
||||
if (length == 0) {
|
||||
throw malformed_sstable_exception("Estimated histogram with zero size found. Can't continue!");
|
||||
co_await coroutine::return_exception(malformed_sstable_exception("Estimated histogram with zero size found. Can't continue!"));
|
||||
}
|
||||
|
||||
// Arrays are potentially pre-initialized by the estimated_histogram constructor.
|
||||
@@ -694,7 +694,7 @@ future<> parse(const schema& s, sstable_version_types v, random_access_reader& i
|
||||
co_await parse(s, v, in, sh.max_bin_size, a);
|
||||
auto length = a.elements.size();
|
||||
if (length > sh.max_bin_size) {
|
||||
throw malformed_sstable_exception("Streaming histogram with more entries than allowed. Can't continue!");
|
||||
co_await coroutine::return_exception(malformed_sstable_exception("Streaming histogram with more entries than allowed. Can't continue!"));
|
||||
}
|
||||
|
||||
// Find bad histogram which had incorrect elements merged due to use of
|
||||
@@ -800,7 +800,7 @@ future<> sstable::read_toc() noexcept {
|
||||
// but if we so much as read a whole page from it, there is definitely something fishy
|
||||
// going on - and this simplifies the code.
|
||||
if (size >= 4096) {
|
||||
throw malformed_sstable_exception("SSTable TOC too big: " + to_sstring(size) + " bytes", filename(component_type::TOC));
|
||||
return make_exception_future<>(malformed_sstable_exception("SSTable TOC too big: " + to_sstring(size) + " bytes", filename(component_type::TOC)));
|
||||
}
|
||||
|
||||
std::string_view buf(bufptr.get(), size);
|
||||
@@ -821,18 +821,20 @@ future<> sstable::read_toc() noexcept {
|
||||
}
|
||||
}
|
||||
if (!_recognized_components.size()) {
|
||||
throw malformed_sstable_exception("Empty TOC", filename(component_type::TOC));
|
||||
return make_exception_future<>(malformed_sstable_exception("Empty TOC", filename(component_type::TOC)));
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
}).then_wrapped([this] (future<> f) {
|
||||
try {
|
||||
f.get();
|
||||
} catch (std::system_error& e) {
|
||||
if (e.code() == std::error_code(ENOENT, std::system_category())) {
|
||||
throw malformed_sstable_exception(filename(component_type::TOC) + ": file not found");
|
||||
return make_exception_future<>(malformed_sstable_exception(filename(component_type::TOC) + ": file not found"));
|
||||
}
|
||||
throw;
|
||||
return make_exception_future<>(e);
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
|
||||
}
|
||||
@@ -1004,12 +1006,13 @@ future<> sstable::read_simple(T& component, const io_priority_class& pc) {
|
||||
f.get();
|
||||
} catch (std::system_error& e) {
|
||||
if (e.code() == std::error_code(ENOENT, std::system_category())) {
|
||||
throw malformed_sstable_exception(file_path + ": file not found");
|
||||
return make_exception_future<>(malformed_sstable_exception(file_path + ": file not found"));
|
||||
}
|
||||
throw;
|
||||
return make_exception_future<>(e);
|
||||
} catch (malformed_sstable_exception &e) {
|
||||
throw malformed_sstable_exception(e.what(), file_path);
|
||||
return make_exception_future<>(malformed_sstable_exception(e.what(), file_path));
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1309,12 +1312,12 @@ future<> sstable::update_info_for_opened_data() {
|
||||
} catch (const std::system_error& ex) {
|
||||
// ignore summary that isn't present in disk but was previously generated by read_summary().
|
||||
if (ex.code().value() == ENOENT && c == component_type::Summary && _components->summary.memory_footprint()) {
|
||||
return uint64_t(0);
|
||||
return make_ready_future<uint64_t>(0);
|
||||
}
|
||||
throw;
|
||||
return make_exception_future<uint64_t>(ex);
|
||||
}
|
||||
}
|
||||
return f.get0().allocated_size;
|
||||
return make_ready_future<uint64_t>(f.get0().allocated_size);
|
||||
});
|
||||
}).then([this] (uint64_t bytes) {
|
||||
_bytes_on_disk += bytes;
|
||||
@@ -1981,7 +1984,7 @@ future<> sstable::check_create_links_replay(const sstring& dst_dir, int64_t dst_
|
||||
if (!same) {
|
||||
auto msg = format("Error while linking SSTable: {} to {}: File exists", src, dst);
|
||||
sstlog.error("{}", msg);
|
||||
throw malformed_sstable_exception(msg, _dir);
|
||||
return make_exception_future<>(malformed_sstable_exception(msg, _dir));
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
@@ -2565,7 +2568,7 @@ future<> sstable::mutate_sstable_level(uint32_t new_level) {
|
||||
|
||||
auto& p = entry->second;
|
||||
if (!p) {
|
||||
throw std::runtime_error("Statistics is malformed");
|
||||
return make_exception_future<>(std::runtime_error("Statistics is malformed"));
|
||||
}
|
||||
stats_metadata& s = *static_cast<stats_metadata *>(p.get());
|
||||
if (s.sstable_level == new_level) {
|
||||
|
||||
Reference in New Issue
Block a user