Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86737 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44498 invoked from network); 17 Jun 2015 21:30:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2015 21:30:33 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.182 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.182 mail-lb0-f182.google.com Received: from [209.85.217.182] ([209.85.217.182:35029] helo=mail-lb0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/40-42507-6F6E1855 for ; Wed, 17 Jun 2015 17:30:31 -0400 Received: by lbbwc1 with SMTP id wc1so40436034lbb.2 for ; Wed, 17 Jun 2015 14:30:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=DnVoUMh0Zo5HfsKxxU/cfbEvOXZGsiQW/zP5Zsa4lPA=; b=UDh4mU3JShWWXm98pWM6trTsWWah+Ei2Lmf6DoyBw/BP+mF8gENaiBgKvTaTfM+pfy Yk74LpQt0luU6yG7+DrcXExmj1KxIfUyDrJhgY5xeVVT1TujDx7+QJ6GHgpkvYIjV8tu 6FTh+xDh7KMpEzq+31+r0ZNMqdj1dmnooqXvcUezgkfcTwodLuKD+wj5Wn+DCzIL7nt1 Z+lBtqpX+ZHo2y26j01zEOj3ndhc43xNLOIufla4QSGNuQ5iKw5ou9WEwYlmRK5Ewq0J wZ6ukEnSkBENj8vpnHMTkNoAsWzxdyLBAlA7yOKdiE/xX476agl7cjPpsu5edgH7dKKO gCcg== MIME-Version: 1.0 X-Received: by 10.112.118.206 with SMTP id ko14mr9978057lbb.28.1434576627234; Wed, 17 Jun 2015 14:30:27 -0700 (PDT) Received: by 10.25.90.75 with HTTP; Wed, 17 Jun 2015 14:30:27 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Jun 2015 17:30:27 -0400 Message-ID: To: Kevin Bradwick Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] RFC - making the Exception class abstract From: ircmaxell@gmail.com (Anthony Ferrara) Kevin, On Wed, Jun 17, 2015 at 4:41 PM, Kevin Bradwick wrote: > Hello! > > This is my first post to the internals list so please forgive me if I have > not followed the rules precisely! > > I've had an idea to improve how developers use exceptions within PHP. I'd > like to add an RFC but as per the instructions on the site > , I am sending this email first gauge > reaction as an initial idea. > > The idea is to change the base Exception > class to be abstract. The > reason for this is to encourage developers to extend it to create meaning > exceptions or use the standard SPL exceptions. The documentation states > that it's the base class for all exceptions, which kind of encourages my > thought process. > > Too many times have I seen developers throwing Exceptions when what they > really needed was something that gave it context like > InvalidArgumentException or RuntimeException. Yes, I agree this is > something to tackle at code review (and I do) but I feel PHP doesn't help > the situation by making it an instantiatable class. I struggle to think of > a valid reason where it makes sense to throw the root Exception class. > Catching the root Exception class is a different matter and there are > perfectly valid cases for doing it. > > So, what does everyone think? Is it worth me pursing the RFC with full > details of the idea or am I on my own with this one? > > Many thanks! > Kevin Changing the existing Exception class to be abstract would break a metric ton of code. Simply on that metric alone it would be a hard sell. I think you'd need an exceptionally strong justification for it, beyond "using typed exceptions is better". Instead, I think we should solve the problem with education. Perhaps the documentation can better detail out why devs shouldn't directly throw exception but instead use typed exceptions...? My $0.02 at least... Anthony