From: Ricardo Signes Date: Thu, 21 Oct 2010 18:52:22 +0000 (-0400) Subject: document args to finally{} block X-Git-Tag: Try-Tiny-0.07~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6e0f0df8b42e08fdce8f9378ea143a2d0a7742c;p=p5sagit%2FTry-Tiny.git document args to finally{} block --- diff --git a/lib/Try/Tiny.pm b/lib/Try/Tiny.pm index 90e188f..47752a6 100644 --- a/lib/Try/Tiny.pm +++ b/lib/Try/Tiny.pm @@ -280,6 +280,22 @@ executed in the event of a successful C or if C is run. This allows you to locate cleanup code which cannot be done via C e.g. closing a file handle. +When invoked, the finally block is passed the error that was caught. If no +error was caught, it is passed nothing. In other words, the following code +does just what you would expect: + + try { + die_sometimes(); + } catch { + # ...code run in case of error + } finally { + if (@_) { + print "The try block died with: @_\n"; + } else { + print "The try block ran without error.\n"; + } + }; + B. C will not do anything about handling possible errors coming from code located in these blocks.