Re: Re: [RFC] Exceptions in the engine

From: Date: Thu, 19 Feb 2015 15:46:47 +0000
Subject: Re: Re: [RFC] Exceptions in the engine
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-83212@lists.php.net to get a copy of this message
Exception declares protected properties that may be used in child classes directly. This is not possible with interface. Thanks. Dmitry. On Thu, Feb 19, 2015 at 6:31 PM, Dan Ackroyd <danack@basereality.com> wrote: > On 19 February 2015 at 09:54, Dmitry Stogov <dmitry@zend.com> wrote: > > > I think we may introduce the following hierarchy > > the existing code that caught Exception is going to be unaffected. > > We could do that. But it's not obviously correct, and ought to be > justified as to why it would be the correct thing to do. > > The problem of people needing to catch every type of exception could > also be solved by using a common interface. > > class EngineException implements ExceptionInterface {} > class Exception implements ExceptionInterface {} > > try { > foo(); > } > catch(ExceptionInterface $exception) { > //catches everything. > } > > This avoids a requirement for all exceptions to extend from a common > base class. The interface for exceptions would be the current > Exception classes methods, excluding the constructor. > > > We thought about "Throwable" or "Catchable" interface, but this change > > would require more changes and will make more BC breaks. > > Please can you explain what those problems are? > > > cheers > Dan >

« previous php.internals (#83212) next »