in reply to Re: Argument stringification in __WARN__ and __DIE__
in thread Argument stringification in __WARN__ and __DIE__

Thanks for the reply.
That could almost be workable. Also I could also do:
die ["Some error happened", {other => 'args'}];


Downsides are that it looks ugly if you don't have an __DIE__ handler - and it still doesn't work for __WARN__.

my @a=qw(random brilliant braindead); print $a[rand(@a)];

Replies are listed 'Best First'.
Re: Re: Re: Argument stringification in __WARN__ and __DIE__
by broquaint (Abbot) on May 15, 2003 at 10:01 UTC
    Downsides are that it looks ugly if you don't have an __DIE__ handler
    If you overload the stringification operator for your object then you should be able to get the desired behaviour for die.

    Another option is that you could overload die and warn e.g

    BEGIN { *CORE::GLOBAL::die = sub { CORE::die("$_[0]->{type}: $_[0]->{msg}\n"); }; *CORE::GLOBAL::warn = sub { CORE::warn("$_[0]->{type}: $_[0]->{msg}\n"); }; } warn { type => "warntest", msg => "missing point" }; die { type => "dietest", msg => "and I'm done" }; __output__ warntest: missing point dietest: and I'm done
    Extraordinarily hackish, but at least there's an option :)
    HTH

    _________
    broquaint