chore: consolidate,add try blocks, throw more
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
44a2f4148e
commit
7972a851a0
|
@ -76,7 +76,8 @@ auto Accumulator::get_random_data(const unsigned int& n_bytes) -> std::string {
|
||||||
data = this->Gen->generate_random_data(n_bytes);
|
data = this->Gen->generate_random_data(n_bytes);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
fmt::print("{}", e.what());
|
// FIXME: handle the exception
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +87,8 @@ auto Accumulator::call_reseed(const std::string& seed) -> void {
|
||||||
this->Gen->reseed(seed);
|
this->Gen->reseed(seed);
|
||||||
}
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
fmt::print("{}", e.what());
|
// FIXME: handle the exception
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <exception>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
@ -39,16 +40,21 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const std::vector<char>& event) override {
|
void add(const std::vector<char>& event) override {
|
||||||
this->pool_id = (this->where_to) % 32;
|
try {
|
||||||
fmt::print("[i] add to pool {}\n", this->pool_id);
|
this->pool_id = (this->where_to) % 32;
|
||||||
int ret{this->_pools->at(this->pool_id)
|
fmt::print("[i] add to pool {}\n", this->pool_id);
|
||||||
.add_entropy(this->_source_id, event)};
|
int ret{this->_pools->at(this->pool_id)
|
||||||
if (ret == 1) {
|
.add_entropy(this->_source_id, event)};
|
||||||
throw std::runtime_error(
|
if (ret == 1) {
|
||||||
"\t[!] event_adder: error adding event!\n");
|
throw std::runtime_error(
|
||||||
|
"\t[!] event_adder: error adding event!\n");
|
||||||
|
}
|
||||||
|
// FIXME: this WILL overflow, too
|
||||||
|
++where_to;
|
||||||
|
}
|
||||||
|
catch (std::exception& e) {
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
// FIXME: this WILL overflow, too
|
|
||||||
++where_to;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,17 +46,19 @@ auto UrandomEntropySrc::event(accumulator::EventAdderImpl& adder) -> void {
|
||||||
fmt::print(stderr, "{}", msg);
|
fmt::print(stderr, "{}", msg);
|
||||||
throw std::runtime_error(msg);
|
throw std::runtime_error(msg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (std::ifstream::failure& e) {
|
|
||||||
fmt::print("io exception caugth: {}\n", e.what());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
adder.add(this->bytes);
|
adder.add(this->bytes);
|
||||||
std::memset(this->bytes.data(), 0x00, this->bytes.size()); // clear out
|
std::memset(this->bytes.data(), 0x00, this->bytes.size()); // clear out
|
||||||
}
|
}
|
||||||
|
catch (std::ifstream::failure& e) {
|
||||||
|
// FIXME: handle the exception
|
||||||
|
fmt::print("io exception caugth: {}\n", e.what());
|
||||||
|
throw;
|
||||||
|
}
|
||||||
catch (std::exception& e) {
|
catch (std::exception& e) {
|
||||||
|
// FIXME: handle the exception
|
||||||
fmt::print("[!] ues: exception caugth: {}\n", e.what());
|
fmt::print("[!] ues: exception caugth: {}\n", e.what());
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue