I was reading over some code that used the MIDI module, and saw the
C<write_to_file> method.  I began wondering, how does one report the
error if he feels like it, but let the module report the error if not,
in a concise way.

What about something along the lines of a C<catch> statement modifier,
like:

$opus.write_to_file($file) catch die "Couldn't write to $file: $!\n";

Remember that a C<try> without a C<CATCH> catches all exceptions and returns C<undef> (the same as a Perl 5 C<eval> block does).

So you just want:

        try { $opus.write_to_file($file) }
                err die "Couldn't write to $file: $!\n";

Damian



Reply via email to