Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87357 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51153 invoked from network); 28 Jul 2015 22:30:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jul 2015 22:30:07 -0000 Received: from [127.0.0.1] ([127.0.0.1:2091]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id F5/F4-22108-F6208B55 for ; Tue, 28 Jul 2015 18:30:07 -0400 Authentication-Results: pb1.pair.com header.from=markus@malkusch.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=markus@malkusch.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain malkusch.de designates 31.47.225.241 as permitted sender) X-PHP-List-Original-Sender: markus@malkusch.de X-Host-Fingerprint: 31.47.225.241 malkusch.de Received: from [31.47.225.241] ([31.47.225.241:47234] helo=malkusch.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/54-22108-945F7B55 for ; Tue, 28 Jul 2015 17:34:04 -0400 Received: from x55b38494.dyn.telefonica.de ([85.179.132.148] helo=[192.168.1.30]) by malkusch.de with esmtpsa (TLSv1.2:DHE-RSA-AES128-SHA:128) (Exim 4.84) (envelope-from ) id 1ZKCVa-0006of-Tm for internals@lists.php.net; Tue, 28 Jul 2015 23:33:59 +0200 Message-ID: <55B7F53A.30308@malkusch.de> Date: Tue, 28 Jul 2015 23:33:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2PN1HCmCEXnruLkoxKdLWPdwcOEtbIhKs" X-Spam-Score: -1.0 X-Spam-Score-Int: -9 X-Spam-Level: - Subject: Throwable::addSuppressed() From: markus@malkusch.de (Markus Malkusch) --2PN1HCmCEXnruLkoxKdLWPdwcOEtbIhKs Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi PHP So I read that there's this Throwable interface coming. Great! How about extending it with one further method: void Throwable::addSuppressed(Throwable exception) Semantic is the same as Java's Throwable.addSuppressed()=C2=B9. Why? Well consider a code fragment which wants to close a resource during an exception: } catch (Exception $e1) { try { $resource->close(); throw $e1; } catch (ResourceException $e2) { // The information about $e2 is lost. throw $e1; } } Currently PHP has no method to propagate both $e1 and $e2. With Throwable::addSuppressed() $e2 could be added as a suppressed exception to $e1: } catch (Exception $e1) { try { $resource->close(); } catch (ResourceException $e2) { e1->addSuppressed($e2); } throw $e1; } To make this information useful (for e.g. a logger) there's one further method needed: Throwable[] Throwable::getSuppressed() So PHP, what do you think, might a RFC find acceptance? Best wishes Markus Malkusch [1]: http://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#addSupp= ressed-java.lang.Throwable- --2PN1HCmCEXnruLkoxKdLWPdwcOEtbIhKs Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlW39UAACgkQ/RRK96H7DMT+AACcD7nUPxti6JMy/tRv85D+RDEI iAYAn1ye2OF5JaEvh2H8rvRdjdtM+t5m =j52S -----END PGP SIGNATURE----- --2PN1HCmCEXnruLkoxKdLWPdwcOEtbIhKs--