Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127231 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 1FDDA1A00BC for ; Mon, 28 Apr 2025 21:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745874425; bh=DY0TSwRR40k5fqJTgYOpHSsa8E7ve5gLbQI31397Q+w=; h=Date:From:To:In-Reply-To:References:Subject:From; b=jwA+11peXfJotjxu0yAs7CCPg784+oGjuvXYlghsMcJ0yWCxlQnG29mXrEKY4tNaf aK1cPMNqQRh6q77MeXoc/8Sc0azBWYv+jcJAzJ2zFTVacw40PWhle3cXqpbJnKuzZd gfKXMRVndW0B6viwQeJC9+suxt7uPV5HRfaWXBciTW0fovHOcOiJPFi4+xxJB8+ciP hVBni+bSil8tq25QYBCb+UWM+QxJSTcXtNwdq8scFiv59xp0AGqGusxfVXwl4zIb5R vcsTRKIVNOuSRx9CkdI2ja9FmgMifoi4ieyOHCXe1i1MjuKSkt1OsqyGYI1I0T0t87 QFnOZOk+hYufA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C013A1801DD for ; Mon, 28 Apr 2025 21:07:04 +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=-1.4 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 28 Apr 2025 21:07:04 +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 0472B114025B for ; Mon, 28 Apr 2025 17:09:21 -0400 (EDT) Received: from phl-imap-06 ([10.202.2.83]) by phl-compute-10.internal (MEProxy); Mon, 28 Apr 2025 17:09:21 -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=1745874560; x=1745960960; bh=wzcv7zSA6ReNGb7JaNlMd EMj7M3fR+XRUl948cNYGx8=; b=ai7gipkn5r4S4un6AMHajFxzrDBd9vOGYMyZr uZhmQ/E8OsiRjkj9XZ1uiQFmlrbTuhjSVLH4tEhST2tJH58puiztUP7xxmfNP2Jf WtCVcTlSlHNNdzkMgP6D+YvaYt2xCIeebgXGpAHYgE400xNzCdTSXo4beBoDJFc+ Iiy4Wa/GWSuteqvSAn73RztBAgyV4mIPoHwfkqczOeTTrSjTWN1jZ5WwHRnfJFjw 1BfS4uvprjBPMF2fSXhBlh8BLYPuClU4vVcvF6+vFzchuJGZSJL3L3YXPVXlxefD mMPP9vD+JYGcVElJWnxvtDz2ivnwNNnHn20+MHpsLDrIDNtNg== 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=1745874560; x=1745960960; bh=w zcv7zSA6ReNGb7JaNlMdEMj7M3fR+XRUl948cNYGx8=; b=ayQk+FuUHeABFdNy4 x6+jzRU5CnAn2H7IdR1cqgaIeTyKYTpO/8WiOR5obEHq51TpVvGZKLqHDhuo6fRH 05jc1AJZKruyLTrcEviEf5xf0U6IiD/+Y5y4aG92SnVtAp5rOAQqdwSa9Tvx6DxH jtSjkHtCQJJuLj3YuoCXDaKLPc0CqrA8BSzw9Ho7mdd3HWXbTkVKHudAMJNSqaZI AEnTp6KO+d+HchcBzQlZa7wEl832s+dnKel4T4931ziEhCOjKEw80ts6+VHKgvBW FCRrWaGM9p1BGo62EGjh4xMiJ9Gx+KmV0Ty9VqGXgmDj06spdWPL1W+XyCUtFBai vb72g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieduleelucetufdoteggodetrf 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 970AE29C0072; Mon, 28 Apr 2025 17:09:20 -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 16:09:00 -0500 To: "php internals" Message-ID: In-Reply-To: References: <8c35314a-e307-4018-8685-39d7a7923cbe@bastelstu.be> <4de85c52-9c04-4e66-9654-af1a377015e1@app.fastmail.com> 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 Mon, Apr 28, 2025, at 3:30 PM, Tim D=C3=BCsterhus wrote: > Hi > > On 4/28/25 22:04, Larry Garfield wrote: >> Holy cow, thank you for this bit. The inability to tell what went wr= ong programmatically without string parsing the exception message is one= of my biggest pet peeves in current exceptions. > > Anything particular from the standard library? It might be possible to=20 > improve this for existing extensions without creating an entirely new=20 > hierarchy and without an RFC. I was thinking the same thing. The main one that comes to mind is Argum= entCountError, where while doing some interesting meta-coding I had to d= o this: https://github.com/Crell/AttributeUtils/blob/master/src/Analyzer.php#L123 >> * "Non-base exceptions MAY define additional properties to provide ad= ditional metadata about the nature of the error." I am tempted to stren= gthen that to SHOULD, to help drive the point home. Maybe use a SHOULD,= and at the end add "unless the nature and details of the error is fully= defined by the exceptions' type." > > I would not want to encourage authors to add additional properties =E2= =80=9Cjust=20 > in case=E2=80=9D they might be useful by using a SHOULD phrasing. I al= so expect=20 > this to be something that can be resolved by simple agreement during t= he=20 > RFC discussion or review of the implementation. > > I historically also had almost no cases where additional properties on=20 > an exception provided value for *programmatic consumption*. Most of th= e=20 > cases could be decided by class name alone and the message was=20 > sufficient to provide additional details for the human reader in the=20 > application logs (e.g. the exact nature of a DNS resolution error). Ke= ep=20 > in mind that additional properties cannot be handled in a generic=20 > fashion, so they are useful for programmatic consumption when catching= a=20 > specific exception class only. > >> * Would allowing an extension-tagging interface instead of a base cla= ss be an option? It still allows for catching "anything thrown by this = extension", which I presume is the goal. If not, why? > > See the =E2=80=9CChoice of Base Exception=E2=80=9D section in=20 > https://github.com/php/php-src/pull/9220. That seems to be about not having a common interface for both the Error = and the Exception, which makes sense. I'm talking about `interface Exam= pleException {}` and `interface ExampleError {}`, instead of `class Exam= pleException extends Exception {}`, etc. --Larry Garfield