RE: [PHP-DEV] trigger_error() enhancements

From: Date: Tue, 16 Apr 2013 16:36:07 +0000
Subject: RE: [PHP-DEV] trigger_error() enhancements
References: 1  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
At 08 April 2013 21:51 Thomas Anderson wrote:

> I was thinking it'd be useful if people could switch between throwing
> exceptions and displaying errors. If throw were a function and not a
> language construct one could do $function($error) where $function was a
> string equal to either 'trigger_error' or 'throw'. But alas that's not
> possible.

    function throw_exception($message, $level = 0)
    {
        throw new Exception($message, $level);
    }

;-)

For the record I think that the PHP errors vs. exceptions model kinda
sucks, but I also think that what you propose is even worse (no offence).

> Also, I think it'd be useful if developers could specificy which line
> number and file name the error [...] displays

This I could kind of go with. In particular it would be good to control the
file/line no *printed* without affecting the stack trace. If this is done
though, I would only want to specify how far up the call stack to go to get
this information, rather than actually specifying the values used.

Best Regards

Chris Wright (DaveRandom)


Thread (4 messages)

« previous php.internals (#67089) next »