utils.cpp 566 B

1234567891011121314151617181920212223242526
  1. #include "config.h"
  2. #include "utils.h"
  3. #include <cassert>
  4. #include <exception>
  5. #include "alstring.h"
  6. #include "core/logging.h"
  7. void eax_log_exception(std::string_view message) noexcept
  8. {
  9. const auto exception_ptr = std::current_exception();
  10. assert(exception_ptr);
  11. try {
  12. std::rethrow_exception(exception_ptr);
  13. }
  14. catch(const std::exception& ex) {
  15. ERR("%.*s %s\n", al::sizei(message), message.data(), ex.what());
  16. }
  17. catch(...) {
  18. ERR("%.*s %s\n", al::sizei(message), message.data(), "Generic exception.");
  19. }
  20. }