2013/12/07

Futures advent day 7

Day 7 - Failures with Values

Yesterday we saw how we can use an else block to catch an exception and make it return a different value, including a success. Of course, it was a rather blunt way to handle a failure because it just turned any failure into a 599 HTTP status.

This is perhaps a good time to explain that, like done can be passed a list of multiple values for on_done and then to receive, so too can fail. The first value in this list must be true and ought to be well-behaved as a string, because get will use it as the exception it will die() with if it has to. Any other values in the list are ignored by get, but are passed in to on_fail and else.

Lets now make a better version of GET_checked that passes the failing HTTP response along with the failure.

No comments:

Post a Comment

About Me

Paul is a Perl and C programmer. His CPAN user id is PEVANS.
Having worked for a number of IT companies, both large and small, he is now self-employed and works as a contractor; primarily in Perl, but also dabbling in such diverse topics as C, systems design and small-scale electronics as the need arises. Enquire by email for more detail.