While I am a devout and enthusiastic Perl proponent, there are things that I wish Perl had, or had done differently. One of these is the lack of a clearly-defined exception framework. It’s one of the (very) few things I think Java does better than Perl. Over the years, CPAN has been host to several variations on try/catch-style syntactic sugar. But I now have a favorite: Try::Tiny.
While I had noticed the module scroll by the CPAN Twitter feed, I hadn’t paid much attention to it at first. I like the idea of clean try/catch, but I haven’t used it in any of my modules because I didn’t want to make the lists of dependencies any longer than they have to be. TryCatch, for example, uses Moose, which is a lot to install simply to have a clean exception model.
Then I read this blog post about it, and became much more interested. First off, Tatsuhiko was showing a lot of enthusiasm for something for something that isn’t Plack or PSGI (just teasing!). But mostly, it was just the relief of having a nice try/catch pair with no dependencies.
Let me say that part again, just in case you’re skimming: NO DEPENDENCIES.
Well, aside from Test::More at build-time, but you have that lying around already, right?
This one is absolutely going into the toolbox for future use. I’m also going to look for places where it seems to be an especially-good fit with other modules. (More on that, later.)
Try::Tiny. Give it a, errrr, try…