123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /// Internal shared header file. Not intended for external use.
- #pragma once
- #include <clickhouse/client.h>
- #include <clickhouse/exceptions.h>
- #include <spdlog/logger.h>
- #include <exception>
- #include <string>
- namespace tsdb_shared {
- struct tsdb_exception : std::runtime_error {
- using std::runtime_error::runtime_error;
- tsdb_exception(const std::string& what, std::exception_ptr nested_exception)
- : std::runtime_error(what), nested_exception_(nested_exception) {}
- std::exception_ptr nested_exception() const noexcept { return nested_exception_; }
- private:
- std::exception_ptr nested_exception_ = nullptr;
- };
- void init_tsdb_env();
- spdlog::logger& logger();
- std::string random_uuid();
- template <typename F>
- auto ex_log_boundary(F&& f) try {
- return f();
- } catch (const clickhouse::Error& e) {
- logger().error("Unhandled stck exception: {}", e.what());
- throw tsdb_exception(e.what(), std::current_exception());
- } catch (const std::exception& e) {
- logger().error("Unhandled generic exception: {}", e.what());
- throw;
- }
- } // namespace tsdb_shared
- // Preludes
- using tsdb_shared::ex_log_boundary;
- using tsdb_shared::logger;
|