feat/108-luajit-lambda #126
@ -36,8 +36,8 @@ class ContextFixture : public ::testing::TestWithParam<Context::Kind> {
|
|||||||
task(param_);
|
task(param_);
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "unexpected exception while async task execution: " << e.what()
|
<< "unexpected exception while async task execution:\n"
|
||||||
<< std::endl;
|
<< e << std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,8 +66,8 @@ class ContextFixture : public ::testing::TestWithParam<Context::Kind> {
|
|||||||
task(param_);
|
task(param_);
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
std::cerr
|
std::cerr
|
||||||
<< "unexpected exception while sync task execution: " << e.what()
|
<< "unexpected exception while sync task execution:\n"
|
||||||
<< std::endl;
|
<< e << std::endl;
|
||||||
std::abort();
|
std::abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@ target_link_libraries(nf7_iface
|
|||||||
)
|
)
|
||||||
target_sources(nf7_iface
|
target_sources(nf7_iface
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
common/exception.cc
|
||||||
version.cc
|
version.cc
|
||||||
PUBLIC
|
PUBLIC
|
||||||
common/dealer.hh
|
common/dealer.hh
|
||||||
common/container.hh
|
common/container.hh
|
||||||
|
common/exception.hh
|
||||||
common/future.hh
|
common/future.hh
|
||||||
common/observer.hh
|
common/observer.hh
|
||||||
common/task.hh
|
common/task.hh
|
||||||
|
28
iface/common/exception.cc
Normal file
28
iface/common/exception.cc
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// No copyright
|
||||||
|
#include "iface/common/exception.hh"
|
||||||
|
|
||||||
|
namespace nf7 {
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& st, const Exception& e) {
|
||||||
|
auto idx = uint32_t {0};
|
||||||
|
auto ptr = &e;
|
||||||
|
while (true) {
|
||||||
|
const auto& loc = ptr->location();
|
||||||
|
st << idx << ": " << ptr->what() << "\n";
|
||||||
|
st << " " << loc.file_name() << ":" << loc.line() << "\n";
|
||||||
|
st << " " << loc.function_name() << "\n";
|
||||||
|
try {
|
||||||
|
ptr->RethrowNestedIf();
|
||||||
|
break;
|
||||||
|
} catch (const Exception& e2) {
|
||||||
|
ptr = &e2;
|
||||||
|
++idx;
|
||||||
|
} catch (const std::exception& e2) {
|
||||||
|
st << idx << ": " << e2.what() << "\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return st;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nf7
|
@ -2,6 +2,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <ostream>
|
||||||
#include <source_location>
|
#include <source_location>
|
||||||
|
|
||||||
namespace nf7 {
|
namespace nf7 {
|
||||||
@ -14,6 +15,12 @@ class Exception : public std::exception, std::nested_exception {
|
|||||||
std::source_location location = std::source_location::current()) :
|
std::source_location location = std::source_location::current()) :
|
||||||
what_(what), location_(location) { }
|
what_(what), location_(location) { }
|
||||||
|
|
||||||
|
void RethrowNestedIf() const {
|
||||||
|
if (auto ptr = nested_ptr()) {
|
||||||
|
std::rethrow_exception(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char* what() const noexcept override { return what_; }
|
const char* what() const noexcept override { return what_; }
|
||||||
const std::source_location& location() const noexcept { return location_; }
|
const std::source_location& location() const noexcept { return location_; }
|
||||||
|
|
||||||
@ -22,4 +29,6 @@ class Exception : public std::exception, std::nested_exception {
|
|||||||
std::source_location location_;
|
std::source_location location_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream&, const Exception& e);
|
||||||
|
|
||||||
} // namespace nf7
|
} // namespace nf7
|
||||||
|
Loading…
x
Reference in New Issue
Block a user