Please tell me more about constructors that use a try-finally block in them?
What is a use case for this being in a constructor?
What is the problem with using “finally” to handle exceptions in constructors?
9 Replies
⌛
This post has been reserved for your question.
Hey @SidKid! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
You might want to use a try with resources or similar to load a file in the constructor or similar
is try with resource just the same thing as try catch and try finally?
it's basically a better (safer, easier to use) way of doing try finally with stuff that's
AutoCloseable
oh so try-resources is its own concept? i thought a generic trerm for try-finally and try-catch
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Try_resources is used usually when there are resources that need to be closed after an exception has been encountered or allow other part of the program to access the same resources.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.