doy / try-tiny

minimal try/catch with proper preservation of $@
http://metacpan.org/release/Try-Tiny
10 stars 15 forks source link

Better document what happens when you don't specify `catch` #12

Closed Flimm closed 10 years ago

Flimm commented 10 years ago

In Java, Python and Javascript, if you do not specify a catch block, the exception is thrown (after executing a final block).

In contrast, when the catch block is ommitted, Try::Tiny will simply behave as if you specified an empty catch block, and will suppress the exception.

I'm not asking for this behaviour to change. I'm just asking that this behaviour be better documented, as I read the documentation and yet this behaviour still surprised me. For example, including a paragraph like this would be very helpful to people like me:

Try::Tiny's try/catch/finally construct behaves very similarly to equivalent constructs in other programming languages, such as Java, Javascript and Python. One difference may surprise you, however: Try::Tiny will treat an unspecified catch block as an empty catch block, suppressing the exception, unlike other languages which will rethrow the exception. You have been warned!

doy commented 10 years ago

Can you submit a pull request for this? One thing that would be worth noting is that while it is different from the behavior in languages like Java, it does follow the same behavior as eval in Perl.

Flimm commented 10 years ago

Here's a pull request. https://github.com/doy/try-tiny/pull/15