summaryrefslogtreecommitdiff
path: root/different_ways_of_making_errors.html
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-29 10:36:20 +0200
committerAki <please@ignore.pl>2022-04-29 10:36:20 +0200
commit27f7b46c2a74a3ff8d89364d343e9c5e0f64446b (patch)
tree0c1bf8a3e0a808396109640fb28dcd592e443ecf /different_ways_of_making_errors.html
parentb2b4cbae3dd63acde48d636d6ba148fc692e8306 (diff)
downloadignore.pl-27f7b46c2a74a3ff8d89364d343e9c5e0f64446b.zip
ignore.pl-27f7b46c2a74a3ff8d89364d343e9c5e0f64446b.tar.gz
ignore.pl-27f7b46c2a74a3ff8d89364d343e9c5e0f64446b.tar.bz2
Added note about windows and reworded monads stuff
Diffstat (limited to 'different_ways_of_making_errors.html')
-rw-r--r--different_ways_of_making_errors.html10
1 files changed, 6 insertions, 4 deletions
diff --git a/different_ways_of_making_errors.html b/different_ways_of_making_errors.html
index c4b9d3f..05227c8 100644
--- a/different_ways_of_making_errors.html
+++ b/different_ways_of_making_errors.html
@@ -66,6 +66,8 @@ $ if ls real_file; then
real_file
True branch with 0
</pre>
+<p>Extreme example of throwing raw error codes at end-users is Windows and its API. I'd encourage you to avoid going to
+such lengths.
<h3>Returning Error Objects</h3>
<p>But you don't need to use numbers necessarily. The only requirement is that you remember about the ability to
@@ -144,10 +146,10 @@ pointer constants forcing compiler and platform implementations into guaranteein
real object and hopefully cause some segmentation faults here and there.
<h3>Returning Wrapped Values</h3>
-<p>Instead of bundling error with the value like Go did, you can wrap the value with an object that will optionally
-indicate an error. This method is a simplified approach taken from functional programming languages that make heavy use
-of monads. They are quite similar with main difference being flow of the error handling. The wrapper can be tailored for
-errors or things like <b>Either</b> from Haskell or <b>std::variant</b> from C++ can be used.
+<p>Instead of bundling error with the value in tuple or some other container like Go did, you can wrap the value with an
+object that will optionally indicate the error. This method may vary from simplified wrapper to a full-pledged monad.
+Depending on where you end up on this spectrum the main difference will be the flow of error handling. You can use
+tailored wrappers or something more generic like <b>Either</b> from Haskell or <b>std::variant</b> from C++.
<p>A naive interface of tailored wrapper could look like this:
<pre>
template&lt;typename T, typename E=const char*&gt;