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

I.10 exceptions clarification #1222

Open
imre-palik opened this issue May 31, 2018 · 5 comments
Open

I.10 exceptions clarification #1222

imre-palik opened this issue May 31, 2018 · 5 comments
Assignees

Comments

@imre-palik
Copy link

imre-palik commented May 31, 2018

As I am not a native speaker of English, the issue might have been in my side, but could somebody make the "what is an error" note a bit easier to read? After reading it a few times, I still don't understand what it is supposed to mean.

As for the section about performance not being a valid reason. I think it should be more clear here that exceptions are not supposed to be used to implement control flow.

Actually at https://softwareengineering.stackexchange.com/questions/189222/are-exceptions-as-control-flow-considered-a-serious-antipattern-if-so-why
There is a pretty clear definition by Mason Wheeler when exceptions should be used. Could we adopt something like that instead of the "what is an error" section?

The other big question that this rule is fails to answer is when to use [[nodiscard]] . As [[nodiscard]] also seems to be a good sollution for the stated reason of this rule.

@cubbimew
Copy link
Member

cubbimew commented Jun 1, 2018

The note currently says

What is an error?
An error means that the function cannot achieve its advertised purpose (including establishing postconditions)

Would "satisfy its contract" be clearer than "achieve its advertised purpose"?

@imre-palik
Copy link
Author

After thinking a bit about this, I think I know what made me hard to understand this.

First of all, the title itself suggests that this rule is about using exceptions for general error handling. And of course the word error is also strongly overloaded, and thus increases the confusion.

Possibly changing the title to "Use exceptions to signal a critical failure to perform a required task"
and replace the word "error" to "faliure" or "serious error" would help.

@MikeGitb
Copy link

MikeGitb commented Jun 4, 2018

Would "satisfy its contract" be clearer than "achieve its advertised purpose"?

Contract is a heavily overloaded term depending on who you speak with, but imho signaling of errors via exceptions is part of the contract.

I think the current formulation is fine. Alternatively I've heard the phrase "can't establish its post conditions" which is more precise, but again it is unclear to me if e.g. vector::push_back really hasn't established it's post conditions if it exits via an exception, but correctly honors the strong exception guarantee.

@imre-palik
Copy link
Author

Would it be possible to simply remove this rule? Secion E does way more justice to this topic.

@hsutter hsutter self-assigned this Jul 9, 2018
@hsutter
Copy link
Contributor

hsutter commented Jul 9, 2018

We aim to clarify. I wrote the original text so I'll take this one. I'll be careful to avoid wording that is confusing with C++20's new contracts feature.

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

4 participants