new_build_system (#18)
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
Reviewed-on: #18
This commit is contained in:
@ -21,51 +21,32 @@
|
||||
*/
|
||||
#include "utils/error.hpp"
|
||||
|
||||
namespace {
|
||||
struct default_exception_handler final
|
||||
: repertory::utils::error::i_exception_handler {
|
||||
void handle_exception(std::string_view function_name) const override {
|
||||
std::cerr << function_name << "|exception|unknown" << std::endl;
|
||||
}
|
||||
|
||||
void handle_exception(std::string_view function_name,
|
||||
const std::exception &ex) const override {
|
||||
std::cerr << function_name << "|exception|"
|
||||
<< (ex.what() == nullptr ? "unknown" : ex.what()) << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
static default_exception_handler default_handler{};
|
||||
|
||||
static std::atomic<repertory::utils::error::i_exception_handler *>
|
||||
exception_handler{
|
||||
&default_handler,
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace repertory::utils::error {
|
||||
std::atomic<const i_exception_handler *> exception_handler{
|
||||
&default_exception_handler};
|
||||
|
||||
void handle_exception(std::string_view function_name) {
|
||||
i_exception_handler *handler{exception_handler};
|
||||
const i_exception_handler *handler{exception_handler};
|
||||
if (handler != nullptr) {
|
||||
handler->handle_exception(function_name);
|
||||
return;
|
||||
}
|
||||
|
||||
default_handler.handle_exception(function_name);
|
||||
default_exception_handler.handle_exception(function_name);
|
||||
}
|
||||
|
||||
void handle_exception(std::string_view function_name,
|
||||
const std::exception &ex) {
|
||||
i_exception_handler *handler{exception_handler};
|
||||
const i_exception_handler *handler{exception_handler};
|
||||
if (handler != nullptr) {
|
||||
handler->handle_exception(function_name, ex);
|
||||
return;
|
||||
}
|
||||
|
||||
default_handler.handle_exception(function_name, ex);
|
||||
default_exception_handler.handle_exception(function_name, ex);
|
||||
}
|
||||
|
||||
void set_exception_handler(i_exception_handler *handler) {
|
||||
void set_exception_handler(const i_exception_handler *handler) {
|
||||
exception_handler = handler;
|
||||
}
|
||||
} // namespace repertory::utils::error
|
||||
|
Reference in New Issue
Block a user