develooper Front page | perl.perl6.users | Postings from January 2019

Re: How do I trap a crash?

Thread Previous
From:
ToddAndMargo via perl6-users
Date:
January 11, 2019 19:05
Subject:
Re: How do I trap a crash?
Message ID:
3f853265-77d9-862f-1a1b-44abc8384a97@zoho.com
 >> Hi All,
 >>
 >> I would like to do a Send Notify when a program of mine
 >> crashes.
 >>
 >> How do I trap a crash?
 >>
 >> Is there a way to see some of the local variables in the
 >> sub that crashes with the trap?
 >>
 >>
 >> Many thanks,
 >> -T

On 1/11/19 10:56 AM, Elizabeth Mattijsen wrote:
> Perhaps https://docs.perl6.org/language/exceptions#Catching_exceptions could be enlightening?
> 
>> On 11 Jan 2019, at 18:54, ToddAndMargo via perl6-users <perl6-users@perl.org> wrote:


Yes. Thank you!

CATCH {
      default {
          $*ERR.say: .payload;
          for .backtrace.reverse {
              next if .file.starts-with('SETTING::');
              next unless .subname;
              $*ERR.say: "  in block {.subname} at {.file} line {.line}";
          }
      }
}

Does the program die afterward?

Each of my subs has

    my Str $SubName = &?ROUTINE.name;

Is there a way to get that in the printout from CATCH?


Many thanks,
-T

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About