Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128337 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 1E5451ADC2B for ; Thu, 31 Jul 2025 09:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753953283; bh=eKjL/3ef1Nl42xHS4/hbebLnN8pSvV86rdmuVSVxKOE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=f/bSwmcxeowW+yNgj3YFOby6t0+Ixpqk2rlmzgt1jKX1U+citf7IWkz6HKOPMfpfi ie9AvYCuDNDBgKu/Wr4E8KdGKQ47/x4v/y7aPf2+uQRFkFuarEmSdadpJLMpW4HQva PloeLnxSzDe4t6CMUpB4fZSUalle1sSUo7zpqWzMf6YpwnN2oBvIex0mJH4kJJ1rSk 9fwazGav1OoYW//wQ5OW20AobM9EZ9iNEyfw9pvpLErd/RmcEMaRKBvgYGDuFuSb/h um3TYorMq0lb9BeZ+7LQ/vCi13HpVjmnM7r02bMX3Qo2FYJoGqpZTHoG2R87WGCYkW nfR+SHuriRT9g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 50DA418005D for ; Thu, 31 Jul 2025 09:14:42 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 ; Thu, 31 Jul 2025 09:14:41 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-b42254ea4d5so459453a12.1 for ; Thu, 31 Jul 2025 02:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753953382; x=1754558182; 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=vLmcUNRiNIIHn8RbToRV0XnJ1WiH1301kf0B4ZUX9hs=; b=XZ2iGPOzO0yY67RRvXsD9usgdlxeERxS/sfZJHv46VFKwU/wIge+h0HF8CiAicdn7B lxNkdZqlTwUV3iXKNMdz50qqnynV2QhjIqipigTfsiel9yvYMnwuOhrO/+SD+v1f4UE3 lj9YdvuP1jW63tnTWoGxXf9KYeXs1oR7siLiJ5WTVuKxk0gHQkQhmA9fHXVRI71sDdTl iSazjUFlMWSnimjN39c6vvCNgb4uTLKD90Zfpo/l4BTvxd6nuPSpyVxqddDQ67YwbAUi ifg7mnuyxbHELrN2ia+SNGmFx8mRoJN80Cj5fJCUhQ9c+LHq+mCvvz2ZjFmy7N+ESk3n M55w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753953382; x=1754558182; 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=vLmcUNRiNIIHn8RbToRV0XnJ1WiH1301kf0B4ZUX9hs=; b=IdrrLeL1aOzq5Z9kswTclut70yspYZvXSUp3BLB/YCRTckUPGMpbST285GcTu25pzg UMH/Jw1u2uawh+qpaMrl2FSdOdWzJxSBQBBqVhXPbv9XYNCJjtR8ORAUiUi+muGeRVKd OtVwD/1/dOoBZvTaIMtfePCS5+hH/Io/2QUuab0LyUc8tJPUBM36x2eBTdCnA6r+g5KL UcZ6w7QOk0P1C3q1WIXgXouaefyP/NaZuh11ScenALm8aY3DbHf6oj+dTu03hyJlZ6wP FbiAUAxzaXhFc5QWrXyWlvqg31uAXXQwtH9X5PdFiE+xd7KQ5x8YC7KRZsHH7WzsOuo4 yQEA== X-Gm-Message-State: AOJu0YzMx28i0iG/jU8Kua2kjpUTXDQ2DDS1tVIfRM3BgZnHz5n7lIB2 G6yxEgsmFTY9o3uIItS9982B+6G+ty/z+rhumFEKwo7Oy2Fak0i/QuRoD2GODNDE6KXhAUcHTTt OjJ2vO8hTvzl7eioJw8kk88oGeV4SWoUlBHPSJ8o= X-Gm-Gg: ASbGncsk0N4ISxr9vgcnYyb2ydTV1B5ofCLjWroo3AW6IuS833PSRy7Eynac1rv/d1o utUk7YKsGC9hHy2x7Q3py4iSxNEaIqwOm8/eG+kTCR2b+RWDLGhy4StMff5vuoE2f7CdXIVxRrB 2d2GXLGYk3RQ36f4DzaUNXXJSfGFwFx+OCzngg7uwrshWcMIwqgRKVERtna0R/UadOhhLFXa/Km zgMpgRa X-Google-Smtp-Source: AGHT+IG8nvyF9c9a85fMrjKvh117W8mqiNKRgT9MWCgnyoTwXjMGPET0ubZJarCypstES8Mid0J894ovCoxgCu/3DCA= X-Received: by 2002:a17:90b:288b:b0:31e:fac5:5d3f with SMTP id 98e67ed59e1d1-31f5de54b78mr9113957a91.16.1753953381849; Thu, 31 Jul 2025 02:16:21 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 31 Jul 2025 12:16:10 +0300 X-Gm-Features: Ac12FXwuiVWKQZwz32ZbR5HnI5LcWc5L_YXI9Qel8aioHYOazOepl4e4Omkzicg Message-ID: Subject: Re: [PHP-DEV] [RFC] Optional Catch Block Body To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000472397063b3618fb" From: xepozzd@gmail.com (Dmitry Derepko) --000000000000472397063b3618fb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 31, 2025 at 10:12=E2=80=AFAM Rob Landers wr= ote: > my empty catches have lengthy comments describing why they are empty in > case a user steps into it, so they can better understand how the framewor= k > works. > > =E2=80=94 Rob > Agree. I prefer to describe why I've wrote it: try { ... } catch (...) { /** * We don't care If it's broken, because we should go further. */ } A few cases from my side: $decoded =3D []; try { $decoded =3D json_decode($unknownData, asArray: true); } catch (JsonException); Almost the same as try { $decoded =3D json_decode($unknownData, asArray: true); } catch (JsonException) { $decoded =3D []; } try { doSmth() } catch (RaceConditionException $e) { // ok, skip 'cause another worker did the same } --=20 Best regards, Dmitrii Derepko. @xepozz --000000000000472397063b3618fb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Jul 31, 2025 at 10:12=E2=80=AFAM = Rob Landers <rob@bottled.codes> wrote:
=C2=A0
my empty catches have lengthy comments describing= why they are empty in case a user steps into it, so they can better unders= tand how the framework works.

=E2=80=94 Rob

Agree. I prefer to describe why I've wrote it:=
try {=C2=A0 ... } catch (...) {
=C2=A0 /**
= =C2=A0 =C2=A0* We don't care If it's broken, because we should go f= urther.
=C2=A0 =C2=A0*/
}

A fe= w cases from my side:

$decoded =3D [];
t= ry {=C2=A0
=C2=A0 $decoded =3D json_decode($unknownData, asArray:= true);=C2=A0
} catch (JsonException);

A= lmost the same as

try {=C2=A0
=C2= =A0 $decoded =3D json_decode($unknownData, asArray: true);=C2=A0
= } catch (JsonException) {
=C2=A0 $decoded =3D [];
}=C2= =A0

try {
=C2=A0 doSmth()
} ca= tch (RaceConditionException $e) {
=C2=A0 // ok, skip 'cause a= nother worker did the same
}


<= /div>--
Best regards,
<= div dir=3D"ltr">Dmitrii Derepko.
=
--000000000000472397063b3618fb--