3 ms·
Some interesting discussion here. First of all it seems that some people are still having a bit muddled vision about what is an exceptional error/condition. Of
by ensiferum 11y ago
Some interesting discussion here.
First of all it seems that some people are still having a bit muddled vision about what is an exceptional error/condition.
Of course you will need to first define what constitutes an exceptional situation in your application and its domain.
The blog post used a file opening as an example. That example implied that in that software, in that particular context
we have a requirement that our file must be opened. If for some reason it cannot be opened we have grounds for an exceptional
condition. When we have this condition we then choose some particular method/means for how to indicate the situation and how
to deal with it.
We can also demonstrate this the otherway around. Someone mentioned as an example something like a (web)server.
Obviously in that application's domain not being able to open and serve some file is just a part of the normal flow.
Clients may make request to resources that do not exist. So in that example that would not be an exceptional circustamce
but the "FILE NOT FOUND" condition is just part of the normal conditional flow of the program.
However in that same server we might be for example reading the initial configuration file when the program is started
and if we fail to open the file then we might have grounds for an exceptional situation.
So to sum this up, what constitutes an exception situtation is all up to the domain of the program. The blog post discussed methods
for dealing with that situation. This is an important point to realize.
Finally a note on assert, yes there are cases when you can't hard fail and core dump on assert as much as you would like to.
For example when implementing API's that define error return values for "hard failure" conditions. Whether this is sensible practice
and makes the software world better or worse is a matter for another discussion.