From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 897421F406 for ; Thu, 14 Dec 2023 19:40:47 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=ol2jhxT/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=cKT7eimf; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 44C9381855; Thu, 14 Dec 2023 19:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1702582840; bh=EpzB/frSFHcfsShHNPL+1Q8mIorcb6f85Uh06f9vvY0=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=ol2jhxT/vn45srXRBDeXS6V2USjUVgMn0ixfEUcee7q/M4z7jGzBxjjsJ9j5+yQ3s NZOmbPBThlaY72YId5M3DuzfFhmom7S9JwxYGKjHn/3JZgmqHY/V990e0kN76EWPFT frjSHghW7qYR5ICjF8uf/W7vSAsW12cs4SKaM9tQ= Received: from wrqvtvvn.outbound-mail.sendgrid.net (wrqvtvvn.outbound-mail.sendgrid.net [149.72.120.130]) by nue.mailmanlists.eu (Postfix) with ESMTPS id A743D8178A for ; Thu, 14 Dec 2023 19:40:36 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=cKT7eimf; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=WANPWNucXoffHPpArvWoQ0mgSWGdfY92aHUvvTcyG+Q=; b=cKT7eimfVODzD4A+k11zsc/+JEo1NXYvEp1giVAPkuFkDt8tHvblEv8NH0j3CTbS0wGF JLUqr74COT61SDB3X0ityja7gouMUhHTGwhreRbT1lVC8C1IJgYD9K7SPQiZtbagzREm0L jBW/GXDuUya6++TbQw46PFK2p/clkvKrmvsBabY7BeaMh7q1uaUkJd71mjhegoeNBh3AQo MUbXj9LaWNvN6BFYVuHSUpHQO2l8oOLJYzzCE8/NiKmkKbsBwuqEIyiY+e40fIXHsnV/BS H7GUHcexn1SEFRConu0fvD7Vm6vgNbF513uiAQxC3sqRreciO1qNmbu92qf5Pujw== Received: by filterdrecv-6bb8954444-svgvh with SMTP id filterdrecv-6bb8954444-svgvh-1-657B5A33-4 2023-12-14 19:40:35.269064277 +0000 UTC m=+272214.907695675 Received: from herokuapp.com (unknown) by geopod-ismtpd-29 (SG) with ESMTP id WRKIhyTcSuyMn_xkhFMqFw for ; Thu, 14 Dec 2023 19:40:35.204 +0000 (UTC) Date: Thu, 14 Dec 2023 19:40:35 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 18083 X-Redmine-Issue-Author: ioquatix X-Redmine-Sender: ioquatix X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 92282 X-SG-EID: =?us-ascii?Q?RXGrw3WrKfUduNFRrzMMcXYHKEABJI9T84jNjq2g6rBTg=2FXhHIicnPoJUXLutJ?= =?us-ascii?Q?tdNFg7BiEDMUtMCwjaLtb0ItKeRyv3NlZm6AYiJ?= =?us-ascii?Q?s0JX4MJkWCsGEOm59L2ktOfEPo8R4GDk+tt3cZo?= =?us-ascii?Q?FP0kQN6szm62Ja4TvtGGjdlpkgOBHBpgPhRTW6G?= =?us-ascii?Q?Ap8F9imNya=2FNXQU40SP=2FKdd4Wn3dJo6Nk1ryajO?= =?us-ascii?Q?MRtsIHyHt3kgH1FVEHuzJhIpOfbKoyFae5k0Wr3?= =?us-ascii?Q?VkLoxu=2FJatYEfj=2FeIEfkw=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: E6Y2PUQY47DO44NMAJAA4RIKNL2HLVBH X-Message-ID-Hash: E6Y2PUQY47DO44NMAJAA4RIKNL2HLVBH X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:115747] [Ruby master Feature#18083] Capture error in ensure block. List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "ioquatix (Samuel Williams) via ruby-core" Cc: "ioquatix (Samuel Williams)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #18083 has been updated by ioquatix (Samuel Williams). Here is a good example of why `$!` is dangerous: https://github.com/ruby/net-ftp/pull/24 I believe the merged fix is also wrong, since flow control can exit without closing the connection. ---------------------------------------- Feature #18083: Capture error in ensure block. https://bugs.ruby-lang.org/issues/18083#change-105679 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- As discussed in https://bugs.ruby-lang.org/issues/15567 there are some tricky edge cases. As a general model, something like the following would be incredibly useful: ``` ruby begin ... ensure => error pp "error occurred" if error end ``` Currently you can get similar behaviour like this: ``` ruby begin ... rescue Exception => error raise ensure pp "error occurred" if error end ``` The limitation of this approach is it only works if you don't need any other `rescue` clause. Otherwise, it may not work as expected or require extra care. Also, Rubocop will complain about it. Using `$!` can be buggy if you call some method from `rescue` or `ensure` clause, since it would be set already. It was discussed extensively in https://bugs.ruby-lang.org/issues/15567 if you want more details. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/