Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62650 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 252 invoked from network); 2 Sep 2012 01:39:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Sep 2012 01:39:20 -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.215.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-lpp01m010-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:57006] helo=mail-lpp01m010-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/1E-17065-6C8B2405 for ; Sat, 01 Sep 2012 21:39:19 -0400 Received: by lahl5 with SMTP id l5so3018151lah.29 for ; Sat, 01 Sep 2012 18:39:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=XJkSnxwVq/k6lTyoEOK3Tm2Gyz+bmAUzTunZQQ4iJuE=; b=mgdG1bzaK5fqVgLmFpvmrYxmwYK7ZrVF5N7gdkYM/9ADpDLMt5ObI2ivdlo5mSpWW7 LGm7Rnzkxwc0NWP2RdqOQXE107kHkPPEzu7hgQh5klAwO+SZief1cxC8Wnrg1vSx6//0 4w5kV0w21oJW4kdVMT/DrK2S++rT1n829W/Y7NEVAmwxa6yTzDH67kFMlkBRWazNsYP2 0UzCKnuuSyE9wNMNgCuOr/8WUdTq/glcQzrOaDaXgWpoenteoxAR1QmoHdUjPyozzGeO eIsG7dqB9ao91dSc+xN6DH//KC86lD3qUDKNK5XEzAdpDuNXbuwQEWaCLclLcnc+Ho86 3XEQ== MIME-Version: 1.0 Received: by 10.112.104.3 with SMTP id ga3mr4051269lbb.77.1346549955509; Sat, 01 Sep 2012 18:39:15 -0700 (PDT) Received: by 10.114.22.1 with HTTP; Sat, 1 Sep 2012 18:39:15 -0700 (PDT) Date: Sat, 1 Sep 2012 21:39:15 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=14dae9d71976c53f3504c8ae1784 Subject: Exceptions Vs Errors From: ircmaxell@gmail.com (Anthony Ferrara) --14dae9d71976c53f3504c8ae1784 Content-Type: text/plain; charset=ISO-8859-1 Hi all, There's been a lot of discussion around whether or not to include exceptions for core (no class implementations) errors or not. There's been a lot said on both sides. However, I'd like to pose the question from a different angle. Right now, I see the biggest problem with errors currently in PHP is that there's no easy way of discerning between error types to be able to handle them. Therefore it's easier to ignore the error than it is to handle it bluntly. For example, I may want to distinguish between failure modes of file_put_contents(). Right now, three types of errors can occur: File not writable (can't open it), Can't write to file (write failed), and Partial write only (but certain bytes were written). http://lxr.php.net/xref/PHP_5_4/ext/standard/file.c#661 Right now, there's no way short of parsing the error string to even attempt to distinguish between them (arguably the first two could be treated the same, but the third could lead to very dangerous situations). Which is non-trivial to say the least... So, while I know there's some discontent about having the core raise exceptions, let me ask the question differently: Without moving to exceptions, how could the current error and error handling mechanisms be improved to make the scenario I posted above easier. To make handling errors just as easy as ignoring them (or preferably easier)...? Thoughts? Anthony --14dae9d71976c53f3504c8ae1784--