Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130680 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 159801A00BC for ; Tue, 21 Apr 2026 12:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1776774814; bh=A1AD9pekhU0IFdjaxAE+8467VRMhS7xL2iTjgnIwsLg=; h=Date:From:To:Subject:In-Reply-To:References:From; b=SnkeCyh6AUO6ORT6PIRk3z4iV9uZxl0PzDW6M3n7PO9flldTNtDnPqemO0zNdoqTP 2GbaqIkxi0sgEAwlh3I82WxakEUAOWqQ2AQYF1oAEPjC8fPF552Ux0KIMaL0ZapjBn gNy/mMjXe6rvzrrKMSiJuw+N+15UYYkVSOidQSwMkCTFr7/fq7jwTTEfu7MxEcRQHS muJn8G8OnHlMMkYCc4mC/Yim/HB6KLGA2qYKL0awSkLwUx0xvSXFEmi4IudPXSHDYL oUwxOSC/uMr0/nqWm9GFhVE33ZyKjsYFWKWeSsnu9Bp5zoaJpPAJFgsubdi27aUxHz 7WjHQhzMXukrg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 82E45180056 for ; Tue, 21 Apr 2026 12:33:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fout-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) (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 ; Tue, 21 Apr 2026 12:33:33 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id D5B831D0012D for ; Tue, 21 Apr 2026 08:33:27 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Tue, 21 Apr 2026 08:33:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; 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=fm2; t=1776774807; x=1776861207; bh=OayNMIfqS7c+kJ6+fAI+BgSE7qFgP/HdbsyTZP5/WVA=; b= Nv9Ukm8/wgsWt/40oAEhMMtYO/qHpduLNVYrLG0LZ9mORtv4IgdIeZB9xkZZoVml n9hG1wSYkPw9yeSXWS5kQEBqWP6494H42HRGsY/6vdxOJNrqDCKUieycrLKPs/Kx Wo5Jw8d4okzEl0vTbZgDre9Bxk9o8Fe8ywEB4CPR8lnb6ZKoNmXcP8OnODxqFlkx 2Lkv1R2m/gNE8y32DgxmiCynrlXixVUtOUPmp+v2kXFPuezE96+QxueIR9iU1TX9 q276P4BhVGe7mKGffWGSQ4vrC4bnZiNvITvRWoFwL2cYkyObs+j2Xzfl4wuEhNwB FifuoR0PQFdX5emf7oJhbA== 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=fm2; t=1776774807; x=1776861207; bh=O ayNMIfqS7c+kJ6+fAI+BgSE7qFgP/HdbsyTZP5/WVA=; b=E226MxtCthQh5A0Gi UT1R9AjYzcSg229vlHMBV6b21VTat8hbZCmOAhLgRNwH+YcQ4SzhQBaxZ/KTT+K+ crkmGRaC7qV2PTL6taA360MgXDNIse3raPKbQLItvJYwiYBVLB8wGZsBMDR/6DaV 05m1Mwi040N5KfLmmMR/6mJN0V1oh60SWh6/pYKJNkSdkpAmH0h8snE+xV/lYmSH +gX3GDJI/l9sPVU5xOCZCb6Z2l9ou7D8LGk7Xz64WIQQ9nBaKOx6QZi7JWS25WhN JcW5CfXlRxnt9toEx/GOwHkWvREG5/aKzjypXsuiwmNLehvJIqrzwI9Mm4k9wX44 BimAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeiudegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepfffhvffufggjfhfkgggtgfesthhqmhdttd erjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehi mhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhepheelff etiefgveduteefudegtdduveeludegueegleehiefhhefgtdekveevgfelnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrphhhph esrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhu thdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 21 Apr 2026 08:33:26 -0400 (EDT) Date: Tue, 21 Apr 2026 13:16:22 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] Context Managers User-Agent: K-9 Mail for Android In-Reply-To: References: <4985896b-c80a-4302-912e-9f572a260fb5@app.fastmail.com> Message-ID: <88716CA9-38E4-45CA-9471-2D8928CF4DE2@rwec.co.uk> Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 15 April 2026 15:52:17 BST, Larry Garfield wr= ote: >>> 3=2E I will say it is weird to have exitContext return an exception; = but what happens if an exception is thrown during exitContext? Why not just= have it return void and throw if you need to throw instead of having two p= aths to the same thing? > >There's a subtle but important difference here: An exception passed throu= gh exitContext() is the original exception from lower in the call stack, an= d its backtrace will be the original location of the error=2E An exception= thrown from within exitContext() itself indicates a failure that the Conte= xt Manager is responsible for, usually an error in the exitContext() logic = itself=2E PHP collects traces when exceptions are constructed, not when they're thro= wn, so this is a distinction without a difference=2E From the outside, it's= impossible to tell the difference between "return $e;" and "throw $e;"=2E That means you have the following options:=20 - throw the passed exception unchanged - return the passed exception, which is equivalent to throwing it - throw a new exception, or fail to catch an exception in the cleanup logi= c, which as Rob points out will hide the passed exception unless you rememb= er to attach it as $previous - return a new exception, which according to the current RFC text will be = completely ignored (is "throw $e" supposed to say "throw $__ret"?) It does seem like it would be more straightforward to have the return valu= e be "void", and leave it to the implementation to throw or not=2E In practice, as you say, "throw unchanged" will be common, but unless that= 's the behaviour of a *null* return (i=2Ee=2E the default if not opted out)= , "throw $e;" seems the natural boilerplate for that=2E=20 Regards, Rowan Tommins [IMSoP]