Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128255 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 CD55D1A00BC for ; Mon, 28 Jul 2025 12:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753704901; bh=qTdvzd/DiUfIw47jhHEd4QxF8xaR0izsnD34oUwwWFs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SgklOAjRXo9YoCkM69S5yAEzBkfRxlu9GLktMX1WymvKzb2aNEd+gDAVufGC1VkEH w0PmrjKolCxVWiyyNYZmX6nlgaCBXKCxGGIk1F1jzpM/LU7kqNfQfnTMp7QPVNPTdE 68jw+augC8c3fpeTLabogH66tdEihz6dae5WfSbx570yEPz8Ll7gu9yTJfHnjq3Eo2 4zNyoie9hnW2fokPvKqgJkhHwtNjB9AWx7XSf+bPvDQsjJTtGkAdGXWKv7Anjb+y+l auWtPOXBJeLamMh/lnizFL44U8uIp2h/lqohoZOqvcKxPOfqUKddW6b9P86PBxmYOQ wgMztuKlPpqjA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9914C1804BE for ; Mon, 28 Jul 2025 12:14:58 +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=-1.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 Jul 2025 12:14:57 +0000 (UTC) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-33097e1133fso43472831fa.1 for ; Mon, 28 Jul 2025 05:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753704999; x=1754309799; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qTdvzd/DiUfIw47jhHEd4QxF8xaR0izsnD34oUwwWFs=; b=IGPrTCazjL5+8tqQjr72aF6od/Wr7QTk9OMKK8M1ijci77/v9NLHaxU2bbEkzsGM5y 0pBoetSfkQnU7uylpNgGVYcWsz+bxB2+nIkzL7Z4MWlFesGBBEWS4QSgK7a2xcUN2GLK no6vxgzAQ2YHKBJ/N69dXvkm9KsqQM7RIwYBGYzXpumyzvhLpzThOSThm/eC7zBPIzeW U6fERDqN5goKICth2LZ7FmX5OmxfRCWhCdjYOdRhEyfHLcDx4iRoLZNZDELUusv9x4xI hDN5NK4xi+6CVuCEAF5BHOykoxUy+2Y3Ev7eTEHd6DDUL07KNRmoOexxCrxH/Hix9kJA 2mBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753704999; x=1754309799; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qTdvzd/DiUfIw47jhHEd4QxF8xaR0izsnD34oUwwWFs=; b=J/h4rnRFj1czhZYWCDt4KCtFBN7EmbkQhZDCoca4+zmnA87tNrIbyUG1OOnQiKKH2q UTeMhXVhSOS6c9G4lvLJnbzTKYlzBnqy8RRrNPEa7V7CoZQuCtN3pEoZ+pe9SCJZIYY4 ZTNC5SdLKRFlIPsuUQj+nWq7DHZpdkFRMoojrjH4hQifag/Mno2bHhua4PIPVBYJJ2aJ eoLYs9a1b5MRY5YDcFMV5ASOxA9nIOWfIeRxjB2u7bUwE4vMYRrr2ZnTlYwHYnPacy3X QGBdUbBB+5TWzxd60Q8PVWnSmxAJErkFdslF+aO2/u0fnjxbW5oDrnetQCLdM1J0i9V0 gKYA== X-Gm-Message-State: AOJu0YxeRLd/fMWGKYukg9axgesyHG406wnsTCTdgjdOQwUsUh5u3cjW 49+3dWDkx895lWRQHL0+mySohTXbQldy2ufrebMAA4ymqunhxqzj7X1YqxdaQFQkT8z0ATeausr uLIbOvjUUMTkLOEa5I3Sz48d4uwsWYhY= X-Gm-Gg: ASbGnctqrXGSSJ7jhfFxw+B6pcCbNwuySpePmc1a4Bz1gq7aGsIHQaxaUYWK51luKXm P047/67k6F39JawXraVbBatlKKVlGDXrnapt6U+ARfudcUENySDAS9ZuBLdcrzyZ19EODmWIR+/ SbSjFnfH28qsn/Oc6//cSX/YNJtzyy3D5oCiYDIZW+7QdWVpVchTMHhR0ZQV+pI+G8IjA5KhSTY wrH1g== X-Google-Smtp-Source: AGHT+IFOSghqmuz/EWV84Z5p7HcZS5mayIJCxzpdVjzXJnXBJW6z+/DmGb6HU4zDuvHf/y6nXEADQUOxCUFDfvyI2S4= X-Received: by 2002:a05:651c:3248:20b0:32b:4903:f1bb with SMTP id 38308e7fff4ca-331ee762385mr18199241fa.13.1753704998341; Mon, 28 Jul 2025 05:16:38 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <73a35675dff31a1eaf76b67af567194e@bastelstu.be> In-Reply-To: Date: Mon, 28 Jul 2025 14:16:11 +0200 X-Gm-Features: Ac12FXwxOYK0wvL7cM69IO3A9V8UqPf_LZC6fYJ6JbuqAS79ri9p_0GFVnCHz08 Message-ID: Subject: Re: [PHP-DEV] [DISCUSSION] User-land Throwable To: =?UTF-8?Q?Rokas_=C5=A0leinius?= Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000778ee8063afc4378" From: kjarli@gmail.com (Lynn) --000000000000778ee8063afc4378 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jul 28, 2025 at 1:50=E2=80=AFPM Rokas =C5=A0leinius wrote: > > On Mon, 28 Jul 2025 at 13:56, Tim D=C3=BCsterhus wrote= : > >> Hi >> >> Am 2025-07-28 11:41, schrieb Dmitry Derepko: >> > A few years ago I found that a library printed error traces wrong. >> > After a little research I found that there was a mix of 3rd party >> > integration error + raised error around the current bridge >> > implementation >> > (http client). >> > >> > There were several PHP applications with microservices architecture >> > which I >> > had access to (docker + sources). >> > >> > So having the message and traces I'd like to have an error chain as it >> > can >> > be done chaining several errors through a new Exception(previous: $e). >> > But PHP does not allow you to manually implement Throwable. Instead yo= u >> > should extend Exception. But after that you still cannot override the >> > getTrace() method because it's final. >> > >> > So my proposal is pretty simple: Remove both restrictions. >> >> I'm afraid I don't quite understand what actual goal you intend to solve >> with the proposal. The description of your use case is very abstract, >> can you provide a real-world example of a use-case you want to enable? >> >> Best regards >> Tim D=C3=BCsterhus >> > > | real-world example of a use-case you want to enable > > Say I am implementing a job runner, I do its error handling, and I want t= o > enrich the caught exception with additional helpful data for debugging. I= n > this process I create a custom exception MyJobHandlerException, but the > trace of the new exception includes my handler code, which the end user > does not care about. I wish to overwrite the trace of the new > MyJobHandlerException instance with the trace from the originally caught > exception, but I cannot. > > I was always sure that the reason behind all methods of \Exception being > final is Larry-Garfield-blogpost length/depth so I never bothered to ask > and made workarounds. > If I understand you correctly; You rethrow the exception, wrapping it in a custom exception class, and you'd like to have a final/composed stacktrace of all the exceptions? https://3v4l.org/m7HIQ#vnull --000000000000778ee8063afc4378 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Jul 28,= 2025 at 1:50=E2=80=AFPM Rokas =C5=A0leinius <raveren@gmail.com> wrote:

On Mon, 28 Jul 2025= at 13:56, Tim D=C3=BCsterhus <tim@bastelstu.be> wrote:
Hi

Am 2025-07-28 11:41, schrieb Dmitry Derepko:
> A few years ago I found that a library printed error traces wrong.
> After a little research I found that there was a mix of 3rd party
> integration error + raised error around the current bridge
> implementation
> (http client).
>
> There were several PHP applications with microservices architecture > which I
> had access to (docker + sources).
>
> So having the message and traces I'd like to have an error chain a= s it
> can
> be done chaining several errors through a new Exception(previous: $e).=
> But PHP does not allow you to manually implement Throwable. Instead yo= u
> should extend Exception. But after that you still cannot override the<= br> > getTrace() method because it's final.
>
> So my proposal is pretty simple: Remove both restrictions.

I'm afraid I don't quite understand what actual goal you intend to = solve
with the proposal. The description of your use case is very abstract,
can you provide a real-world example of a use-case you want to enable?

Best regards
Tim D=C3=BCsterhus

|=C2=A0real-world example of a use-case you want to ena= ble

Say I am implementing a job runner, I do its error handling, and I want to=20 enrich the caught exception with additional helpful data for debugging.=20 In this process I create a custom exception MyJobHandlerException, but=20 the trace of the new exception includes my handler code, which the end=20 user does not care about. I wish to overwrite the trace of the new=20 MyJobHandlerException instance with the trace from the originally caught exception, but I cannot.

I was always sure that the reason behind all methods of \Exception being=20 final is Larry-Garfield-blogpost length/depth so I never bothered to ask and made workarounds.

<= /div>
If I understand you correctly; You rethrow the exception, wrappin= g it in a custom exception class, and you'd like to have a final/compos= ed stacktrace of all the exceptions?

--000000000000778ee8063afc4378--