develooper Front page | perl.perl5.porters | Postings from June 2022

Re: Core exception types [was: Re: Pre-RFC: Improve “wide character” warnings]

Thread Previous | Thread Next
From:
Ovid
Date:
June 14, 2022 18:50
Subject:
Re: Core exception types [was: Re: Pre-RFC: Improve “wide character” warnings]
Message ID:
CA+M4CHs7KO+Ts+yq-rFW4SJbj2aT4A_4ipnBSkadB-DkM=D9nQ@mail.gmail.com
On Wed, Jun 8, 2022 at 6:25 PM Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
wrote:

> > Paul, can you elaborate on the breakage? If try {...} catches
> > non-blessed errors and upgrades them to a Exception::Legacy object
> > which stringifies (or numifies) on demand <snip>
>
> Ah, now that's an interesting thought. Combined with:
>
> On Wed, 8 Jun 2022 16:06:47 +0200
> Alexander Hartmaier <alex.hartmaier@gmail.com> wrote:
>
> > 3) use a new variable that holds the exception object and populate $@
> > with its string representation?
>
> This might actually be a thing.
>
> We can't change the existing behaviour of $@, but we *could* create
> some other variable, say, ${^EXCEPTION}, that would receive these new
> objects, and say that actually the catch var uses that instead:
>
>   try { ... }
>   catch($e) {
>     if($e isa X::Perl::ENOENT) { ... }
>   }
>
> These objects could then have whatever new interface we decided.
> <leonerd@leonerd.org.uk>


And if we want to go even further, this is from the Carp documentation:

BUGS
    The Carp routines don't handle exception objects currently. If called
with
    a first argument that is a reference, they simply call die() or warn(),
as
    appropriate.


Might be something interesting to consider there.

Best,
Ovid
CTO, All Around the World
World-class software development and consulting
https://allaroundtheworld.fr/

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