You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
978B

  1. #include "./result.hpp"
  2. #include <dds/util/env.hpp>
  3. #include <dds/util/log.hpp>
  4. #include <fmt/ostream.h>
  5. #include <neo/sqlite3/error.hpp>
  6. #include <fstream>
  7. void dds::capture_exception() {
  8. try {
  9. throw;
  10. } catch (const neo::sqlite3::sqlite3_error& e) {
  11. current_error().load(e_sqlite3_error_exc{std::string(e.what()), e.code()},
  12. e.code(),
  13. neo::sqlite3::errc{e.code().value()});
  14. } catch (const std::system_error& e) {
  15. current_error().load(e_system_error_exc{std::string(e.what()), e.code()}, e.code());
  16. }
  17. // Re-throw as a bare exception.
  18. throw std::exception();
  19. }
  20. void dds::write_error_marker(std::string_view error) noexcept {
  21. dds_log(trace, "[error marker {}]", error);
  22. auto efile_path = dds::getenv("DDS_WRITE_ERROR_MARKER");
  23. if (efile_path) {
  24. std::ofstream outfile{*efile_path, std::ios::binary};
  25. fmt::print(outfile, "{}", error);
  26. }
  27. }