Open FGasper opened 8 years ago
I wouldn't want to assume any particular exception style, nor do I think further subclassing for overriding is the right approach.
Generally, customization in HTTP::Tiny has been done with callbacks and that might be the way to go. Either on the ::UA object or in the request or both, have a result_callback
that is passed the result hash (or object) prior to returning it. Then users could program their own exception mechanism there.
result_callback => sub {
my $r = shift;
die "Error $r->{status}: $r->{reason}\n" if !$r->{success};
}
I'm open to a pull request along those lines (with tests!) if you want to write it. :-)
It would be useful for this module to throw exceptions on various failures: network failure, 400/500 return code, etc.
Has this kind of operation mode been discussed previously?
Perhaps a simple, overridable
_throw()
method?