Closed JanValiska closed 4 years ago
Hello, i don't know if i use modules correctly, but anyway in my use case the exception is thrown by constructor in module and cannot be caught(terminate is called instead).
#include <iostream> #include "di.hpp" namespace di = boost::di; struct Foo { Foo() { throw std::runtime_error("No way"); } }; struct Bar { Bar(Foo& foo) {} }; int main(int argc, char *argv[]) { try { auto module1 = []() -> di::injector<Foo&> { return di::make_injector(); }; auto module2 = [&]() -> di::injector<Bar&> { return di::make_injector(module1()); }; auto injector = module2(); injector.create<Bar&>(); } catch (...) { std::cerr << "Never caught" << std::endl; } return 0; }
Run result:
terminate called after throwing an instance of 'std::runtime_error' what(): No way [1] 2568 abort (core dumped) ./test
No terminate is called and exception should be catched by catch block.
The PR is merged. You are welcome to check.
Hello, i don't know if i use modules correctly, but anyway in my use case the exception is thrown by constructor in module and cannot be caught(terminate is called instead).
Minimal example
Run result:
Excepted behavior
No terminate is called and exception should be catched by catch block.
Specifications