Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62075 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96513 invoked from network); 7 Aug 2012 00:55:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Aug 2012 00:55:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:41654] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 46/B8-03102-49760205 for ; Mon, 06 Aug 2012 20:55:49 -0400 Received: by lbgc1 with SMTP id c1so3343335lbg.29 for ; Mon, 06 Aug 2012 17:55:45 -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=3ld6qvAWWCsUOXYBPpUQTXalqXxi/9jah2OaE6Usw8Y=; b=QI9OAiT/jbqo2MCGbEroaNiO8sja7X6YiWqUsNdrDyUszueCnW7gwgatWvo8+OdwDP rBeL0KTd+HhY6/ErksLn5lfvXg9qLtKHsE0bPJjDfrr52Uc41XXdskjH6RltSv7Tpm+j ZcwEWx2E2JRBVlqIoEr43Szcv9ZIjHqCPdKbWyF5KIlobJClEU1clKKK/rFxEgQRdseb uWpWLdj2n2zREYFZrJRtcOTboBmT7ib45tfYKD3wdVU6Qp0ykX/L9PJ6WXpp2RYqNstz t04TdssVsLOX1RmaihfjAV2iE5v+tRuv2jQUnUGRbCa57DP9+SY6atxlNki5n4DOm6Vh qOeA== MIME-Version: 1.0 Received: by 10.112.87.161 with SMTP id az1mr2224771lbb.99.1344300945649; Mon, 06 Aug 2012 17:55:45 -0700 (PDT) Received: by 10.112.1.199 with HTTP; Mon, 6 Aug 2012 17:55:45 -0700 (PDT) In-Reply-To: <50200FBD.2010506@sugarcrm.com> References: <501F46BE.4040407@sugarcrm.com> <50200FBD.2010506@sugarcrm.com> Date: Mon, 6 Aug 2012 18:55:45 -0600 Message-ID: To: Stas Malyshev Cc: Ferenc Kovacs , PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Error handling brainstorming From: morrison.levi@gmail.com (Levi Morrison) >> Because checking that the returned variable is `!== FALSE` is *way* >> better than throwing an exception, right? > > Yes, it is. You can control it, unlike the exception which you can not, > unless, again, you wrap everything into try/catch on every kind of > exception possible. > >> This type of thing is one of the main reasons I like PDO more than >> MySQLi. In MySQLi I'm constantly checking return values. In PDO I >> just wrap it all up one try/catch. It's not like if my query fails >> I'm going to try a different one. Most of the time it's just logging >> that something went wrong and reporting it upstream somehow. > > You are using exceptions for normal flow control. It is not what > exceptions should be used for. They are called exceptions for a reason. > It *should* be an exceptional situation if my database queries don't work properly. I've tested my code locally, on a staging environment and sometimes even ran tests on the live server. It is absolutely 100% an exception if something goes wrong, my friend. Opening a file? I have to agree that it should not throw an exception. I was replying more to explain the benefit of exceptions than to refute that one possible use-case.