Re: Assertions

From: Date: Thu, 17 Oct 2013 21:42:42 +0000
Subject: Re: Assertions
References: 1 2 3 4 5 6 7 8 9 10 11  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On 17/10/2013 18:39, J David wrote:
On Thu, Oct 17, 2013 at 1:20 PM, Joe Watkins<[email protected]> wrote: The new implementation doesn't_require_ that you control the flow of execution but_allows_ you to, better than callbacks did. Does this new exception derive from Exception? (Hint: It does.)
Reading through the discussion, I think this point may deserve more prominence: the problem with throwing an exception is that it is possible (and probably quite common) to have a catch block which catches *all* exceptions. Throwing an exception from assert() tangles up any handling you did want to do for failed assertions with the presumably rather different handling you want to do for runtime exceptions. The current implementation allows you to define a callback, and to choose whether assertions are fatal, which means that unit test frameworks and fancy-output wrappers can intercept assertions *without affecting other parts of the code*. The only way to do that with catch blocks would be to have an exception which didn't descend from Exception. -- Rowan Collins [IMSoP]

Thread (36 messages)

« previous php.internals (#69659) next »