develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Exceptions thrown from LEAVE

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
July 7, 2020 22:29
Subject:
Re: Exceptions thrown from LEAVE
Message ID:
20200707232853.2a81955c@shy.leonerd.org.uk
On Tue, 7 Jul 2020 20:43:40 +0200
Christian Millour <cm.perl@abtela.com> wrote:

> You would need a way to access this stack/history in a catch block,
> and maybe to cook it if you dealt with some of the reported issues
> but have to rethrow the exception (with its cooked history) to
> another agent up the ladder to deal with the rest. System support
> would be needed for error raised in system destructors (e.g.
> automatic closing of lexical filehandles).
> 
> I have no clue as to whether this is doable, even with an EV. Might
> be nice though.

Well, indeed that was most of the point of having a new,
natively-recognised representation type for exception values like this.
Once core understands them, it can indeed annotate such extra
information on. It becomes a simple matter of maybe

  catch ($e) {
    warn "something happened...";
    if(my $caused_by = $e->caused_by) {
      warn "which itself was caused by ...";
    }
  }

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

Thread Previous | Thread Next


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