SYNOPSIS

 try { ... };       # mind the ';' !!
 if($@) {           # signals something went wrong

 if(try {...}) {    # block ended normally

 my $x = try { read_temperature() };
 my @x = try { read_lines_from_file() };

 try { ... }        # no comma!!
    mode => 'DEBUG', accept => 'ERROR-';

 try sub { ... },   # with comma
    mode => 'DEBUG', accept => 'ALL';

 try \&myhandler, accept => 'ERROR-';

 print ref $@;      # Log::Report::Dispatcher::Try

 $@->reportFatal;   # re-dispatch result of try block
 $@->reportAll;     # ... also warnings etc
 if($@) {...}       # if errors
 if($@->failed) {   # same       # }
 if($@->success) {  # no errors  # }

 try { # something causes an error report, which is caught
       report {to => 'stderr'}, FAILURE => 'no network';
     };
 $@->reportFatal(to => 'syslog');  # overrule destination

See SYNOPSIS in Log::Report::Dispatcher

DESCRIPTION

The Log::Report::try() catches errors in the block (CODE reference) which is just following the function name. All dispatchers are temporarily disabled by try, and messages which are reported are collected within a temporary dispatcher named try. When the CODE has run, that try dispatcher is returned in $@, and all original dispatchers reinstated.

Then, after the try has finished, the routine which used the "try" should decide what to do with the collected reports. These reports are collected as Log::Report::Exception objects. They can be ignored, or thrown to a higher level try... causing an exit of the program if there is none.

See DESCRIPTION in Log::Report::Dispatcher

DETAILS