Note that there are some explanatory texts on larger screens.

plurals
  1. POTheory on error handling?
    text
    copied!<p>Most advice concerning error handling boils down to a handful of tips and tricks (see <a href="https://stackoverflow.com/questions/231128/c-error-handling-good-sources-of-example-code">this post</a> for example). These hints are helpful but I think they don't answer all questions. I feel that I should design my application according to a certain philosophy, a school of thought that provides a strong foundation to build upon. Is there such a theory on the topic of error handling?</p> <p>Here's a few practical questions:</p> <ul> <li>How to decide if an error should be handled locally or propagated to higher level code?</li> <li>How to decide between logging an error, or showing it as an error message to the user?</li> <li>Is logging something that should only be done in application code? Or is it ok to do some logging from library code.</li> <li>In case of exceptions, where should you <em>generally</em> catch them? In low-level or higher level code?</li> <li>Should you strive for a unified error handling strategy through all layers of code, or try to develop a system that can adapt itself to a variety of error handling strategies (in order to be able to deal with errors from 3rd party libraries).</li> <li>Does it make sense to create a list of error codes? Or is that old fashioned these days?</li> </ul> <p>In many cases common sense is sufficient for developing a good-enough strategy to deal with error conditions. However, I would like to know if there is a more formal/"scholarly" approach?</p> <p>PS: this is a general question, but C++ specific answers are welcome too (C++ is my main programming language for work).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload