Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127228 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 3D4851A00BC for ; Mon, 28 Apr 2025 20:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745870527; bh=qK7gNO+O37/djI96L0QTu0gS87P13+3XIibnCjLcrFw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=AZbffV4m5237ehTKvvw7Lw+OrLKUXmkOX3d3AovzlgrIZ0MUWFPhxuebkdcHk+9UF BIafBdXCr+RB10l0UBVNFbagzdMN9TFDSddCsZF8WtzyqiniDKi/Z0+cLgFRJM7cbR dB1O87t2XyOo98DETxSmQv8q+QkpLKMVk0bq90ko8fZpWEiyW5eEQVDuQ83fP3E0bP c/bRdepj8MpeKdVEN8z7F3VDYL9kBFCbWbQVOM3PnPfxJdxNw1W7gIeuV79KEKaXFN uuzLFFV8e3I1EZWav8UMGeL/r4InQinxJrpLIfdREyt+7B1QlZ/BlPM/aJxjwJu0g5 uh4hp/D2bNS9Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CC149180579 for ; Mon, 28 Apr 2025 20:02:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-a4-smtp.messagingengine.com (fhigh-a4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 28 Apr 2025 20:02:06 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5F36611401DA for ; Mon, 28 Apr 2025 16:04:23 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-10.internal (MEProxy); Mon, 28 Apr 2025 16:04:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to; s=fm3; t=1745870663; x=1745957063; bh=pW+RGJ5j5NlKsD+B8hToO 1blpj2GU5NEhs5QNd8imdE=; b=n9jOxQ9CAg5lewzlfTl7f7CERqAalmw6ureOL xsmRGIc47eTr2c5NFMOsYfA0iwt3kL7DGUMG9PEPwpT9bXUkmMVSAxQ1d2Sm7Ey1 YxdejIC57sLuAsgoCBEKKr1qG9R2OYsgUW6OmfXFQywcB7VDPMZCi4H5y/LWKxyX oDPf8p7WTsOH5bb70KqjvPvHzP9dGl908NPundk+XBVsfUzrTRtOjKTw5b5n0UXO X4BM65ddohYVV5FCueHwokgnWnwvHEt3kJnt4Wyg4Ep0gW2kEg0BSyVI05FN/Rq9 M9Okq8UhfBkh5RhEsN/KBQXtvsHejR4LAfOkTfNrxz2HFFEyA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1745870663; x=1745957063; bh=p W+RGJ5j5NlKsD+B8hToO1blpj2GU5NEhs5QNd8imdE=; b=rf4J9ZMmmaJ+45T+W wuFiX5yVp93lPimCVtlEhxT7vvx+MfOy4NQA4RstvjAsnWqN88E8+Cr7y05wNz7P 46xCIk5TTDHbxwCY51SlUmdrvK2b3cYQC8bE0k7DrKvd1+S0NwaK0REezq/NNyBa JuN5Z+Ul5fhicS5Y6l4Fw2CoF9tHkqOq7w1aH4L/bCDABeWo5F30yR1i0hVy3G21 g2MSrkXOCh9VfdphR/PRkMPmnbuo2a4z5iW96hEKD4JzyjBl2fZ2mhC0ALb9toLj /fyzPY83FL1boRlXs9y8+hgvBUd0uZjC7QBeRetVyUJOTkCnyTi5+QDkPXz3h7cg w1IXg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddviedukeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepofggfffhvffkjghfufgtgfesthhqredtredt jeenucfhrhhomhepfdfnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrh hfihgvlhguthgvtghhrdgtohhmqeenucggtffrrghtthgvrhhnpeehjeefvefgfeduteff ffdvheeiudekieefleevvdduiefgkeehvdevheffvdegteenucffohhmrghinhepghhith hhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmpdhnsggprhgtphhtth hopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehl ihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 18E3C29C0072; Mon, 28 Apr 2025 16:04:23 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T3339c68d3b5f96f0 Date: Mon, 28 Apr 2025 15:04:02 -0500 To: "php internals" Message-ID: <4de85c52-9c04-4e66-9654-af1a377015e1@app.fastmail.com> In-Reply-To: <8c35314a-e307-4018-8685-39d7a7923cbe@bastelstu.be> References: <8c35314a-e307-4018-8685-39d7a7923cbe@bastelstu.be> Subject: Re: [PHP-DEV] [RFC] Throwable Hierarchy Policy for Extensions Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Sun, Apr 27, 2025, at 4:45 PM, Tim D=C3=BCsterhus wrote: > Hi > > On 4/27/25 23:16, Kamil Tekiela wrote: >> The exception message MUST NOT be the only means of distinguishing >> exceptions. Any two exceptions with different messages MUST be >> identifiable either by a unique exception class name or code. > > Thank you. I have used that as the basis for this change: > > https://github.com/php/policies/pull/17/files/7f7bb9bd09f3883bd13a70d7= f61abbc62bfe04a1..dd507261a61cf088d07d9bdca80d91dcc54daf8a > > I've intentionally adjusted the wording to "different cause" rather th= an=20 > "different message" to avoid defining what constitutes a different mes= sage. > > As an example, when the CSPRNG fails, we might want to emit different=20 > error messages depending on the CSPRNG driver (e.g. /dev/urandom vs th= e=20 > getrandom() syscalls), but it's not useful to distinguish these cases=20 > with a different code, since the user does not decide which driver is=20 > used and can't do anything useful with that information. > > Even distinguishing between "/dev/urandom does not exist" and=20 > "/dev/urandom exists, but is a regular file instead of a character=20 > device" probably is only useful within the message itself, since neith= er=20 > is really recoverable from within PHP and allocating and documenting=20 > codes is likely work that helps no one. > > Best regards > Tim D=C3=BCsterhus Holy cow, thank you for this bit. The inability to tell what went wrong= programmatically without string parsing the exception message is one of= my biggest pet peeves in current exceptions. A few other notes: * Should the property be specified as public/readonly? Should it be con= ventional to have accessor methods? (IMO, property FTW, no need for a m= ethod. I already do this in all my exceptions.) * "Non-base exceptions MAY define additional properties to provide addit= ional metadata about the nature of the error." I am tempted to strength= en that to SHOULD, to help drive the point home. Maybe use a SHOULD, an= d at the end add "unless the nature and details of the error is fully de= fined by the exceptions' type." * Would allowing an extension-tagging interface instead of a base class = be an option? It still allows for catching "anything thrown by this ext= ension", which I presume is the goal. If not, why? --Larry Garfield