ID: 48599 Updated by: johan...@php.net Reported By: evert at rooftopsolutions dot nl -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: Any PHP Version: 5.3.0RC3 New Comment:
Only classes can carry information like stacktraces required for tracing Exceptions back to their source. Depending on the Exception class is a clear design decision. Additionally introducing such an interface would break code having a catch-all handler like ... try {...} catch (Exception $e) {....} Previous Comments: ------------------------------------------------------------------------ [2009-06-18 21:41:54] evert at rooftopsolutions dot nl Description: ------------ I'd like to have a 'Throwable' interface. Any class implementing this interface can be 'thrown' as an exception. This is my usecase: I want to implement : interface MyAPP_NotFoundException extends Throwable { } This interface can be freely used by other exception classes, and all it tells my exception handler, is that I'm supposed to send back a '404' status code back to the client. I cannot simply create an abstract class, because this the classes implementing NotFoundException might be part of an unrelated structure and require methods and properties from other ancestor classes. Alternatively (but similarly), I'd like to be able to define an interface that will give certain exceptions the ability to override a statuscode altogether: interface MyAPP_HTTPException extends Throwable { function getHTTPStatusCode(); } 'Throwable' can be a virtual interface, much like 'Traversable'. This will allow me to make sure that any class implementing HTTPException, will also be throwable. Right now I'm simply defining these interfaces without an ancestor interface, which works.. but it's not perfect :) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48599&edit=1