Railway Oriented Programming
Does this argument hold: This pushes the error handling away from the call site, and that is a bad thing. Being that the caller knows best how to handle the errors, so it should instead of passing them down.<p>(Full disclosure, I have seen this talk and read Wlaschins book, but not in a long time, so maybe he did cover this and I forgot.)<p>Eg given:<p><pre><code>    validate
    and-then update-db
    and-then send-email
</code></pre>
What about when validate fails? The error is returned to the caller, which is
maybe suitable. What about when update-db fails? Should there be a retry? Try
another service? Requeue? Tell the user? What about if the send-email fails?<p>Dont you end up with (except with more unwrapping and sub branches)<p><pre><code>   validate
   and-then update-db
   and-then send-email
   and-if (Ok, ok)
   or-if (ValidationError, notify-user)
   or-if (DBError, retry-in-5 or-then retry-remote or-then notify-user)
   or-if (EmailFailed, requeue-email and ok)
</code></pre>
Maybe thats ok?