http://www.perlmonks.org?node_id=1033973


in reply to Try::Tiny catch block with $_ eq ''

What I prefer to use is Exception::Class, in conjunction with Try::Tiny.   You can die (that is, “throw an error”) with an object as well as with a string, and this gives you a well-defined way to communicate between the point of the error and its ultimate handler.   (Wrap “legacy code” sections in a handler that catches the (string ...) exceptions and throws an object containing, among other things, that string.)

An exception class can not only carry any sort of a “payload” (including undef values as-needed), but it is also self-identifying – you have not only the class-name but the entire class hierarchy that you’ve cooked up.