There is a huge misconception about errors captured in every human language - that errors are something bad and rare events that we must avoid at all costs. This nonsense is obviously not applicable to programming (or biology). There is no such thing as error outside human minds.

Error is a mere branch, a possible outcome, a condition - something that may happen. That is it.

It is even more interesting in molecular biology - there is no errors at all. It all critical parts, such as DNA or RNA transcription, if it is a wrong molecular structure it just does not fit (everything is rely on exact pattern matching - every other structure will not match).

The big idea is - there is no errors outside human minds. Only possible expected and unexpected outcomes. Possible outcomes shall be known (learned by experience or observation) and anticipated. Some outcomes are expected, others are not. That is it.

With an error we signal that an outcome is not what we waited (but which we are expecting).

value, ok := cache.Lookup(key)
if !ok {
// ...cache[key] does not exist...

usually we propagate an error condition to the called

resp, err := http.Get(url)
if err != nil {
   return nil, err
Last modified 3 years ago Last modified on Oct 27, 2017, 11:04:58 AM
Note: See TracWiki for help on using the wiki.