Hi,
in a code I am writing right now http://yapcom.pti.co.il/ I used to croak from functions deep down. When testing for such errors I used code like this in my test script: eval { f(); # will croak }; like($@, qr/Bad thing happened/, 'successfully tested bad thing'); Now I am trying to replace the croak/eval error handling with try/catch of Error.pm so in the f() function I replaced the croak('Bad thing happened'); by throw MyError('Bad thing happened'); How am I going to test this ? I came up with the following in the test script: use Error qw(:try); my $ex; try { f(); } catch MyError with { $ex = shift; }; like($ex, qr/Bad thing happened/, 'successfully tested bad thing'); Now $ex is global but I think I cannot test within the catch block. Shall I just add an extra block around the whole snippet above ? Is this a good thing or a bad thing ? Gabor