Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception in ctor not propagated #227

Closed
Brunni opened this issue Apr 4, 2017 · 1 comment
Closed

Exception in ctor not propagated #227

Brunni opened this issue Apr 4, 2017 · 1 comment

Comments

@Brunni
Copy link

Brunni commented Apr 4, 2017

Hi,

I really like having DI in my code it makes it very readable and testable!

My Problem:
If my configuration settings are wrong, the constructor throws an exception stating which value is missing. This exception is swalloed and the program terminates with errorcode 3.

Example ctor

cerr << "Starting ctor" << endl;
config->getEntry("threshold"); // this throws exception
cerr << "ctor finished" << endl;

Result on console: I see the first message and then program terminates.

System:

  • Execution with GTest framework.
  • Windows, Visual Studio 2015.3
@klemen-forstneric
Copy link

I think this happens due to the fact that injector's create method marked as noexcept. When instantiating a dependency throws, the exception isn't caught inside the create, thus terminating the application, because the noexcept 'contract' is breached.

I'm wondering though, about the rationale of making it noexcept?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants