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

Rule S3693: Exception constructors should not throw exceptions #584

Closed
Evangelink opened this issue Jul 21, 2017 · 1 comment
Closed

Rule S3693: Exception constructors should not throw exceptions #584

Evangelink opened this issue Jul 21, 2017 · 1 comment
Assignees
Labels
Type: New Feature This hasn't been here before.
Milestone

Comments

@Evangelink
Copy link
Contributor

RSPEC-3693

It may be a good idea to raise an exception in a constructor if you're unable to fully flesh the object in question, but not in an exception constructor. If you do, you'll interfere with the exception that was originally being thrown. Further, it is highly unlikely that an exception raised in the creation of an exception will be properly handled in the calling code, and the unexpected, unhandled exception will lead to program termination.

@Evangelink Evangelink added this to the near-future milestone Jul 21, 2017
@Evangelink Evangelink added Type: New Feature This hasn't been here before. rules labels Jul 21, 2017
@Evangelink Evangelink modified the milestones: 6.4, near-future Jul 25, 2017
@Evangelink Evangelink self-assigned this Jul 31, 2017
@Evangelink Evangelink modified the milestones: 6.3, 6.4 Aug 2, 2017
@jinek
Copy link

jinek commented Jun 26, 2019

Where does this rule come from? What is the idea behind it?

Asking, because "Not to throw exception" from "somewhere" in c# is not possible. Runtime and .NET itself can throw exception from anyplace where it is necessary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature This hasn't been here before.
Projects
None yet
Development

No branches or pull requests

2 participants