On Thu, Jul 31, 2025 at 10:12 AM Rob Landers <[email protected]> wrote:
> 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 framework
> works.
>
> — 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 = [];
try {
$decoded = json_decode($unknownData, asArray: true);
} catch (JsonException);
Almost the same as
try {
$decoded = json_decode($unknownData, asArray: true);
} catch (JsonException) {
$decoded = [];
}
try {
doSmth()
} catch (RaceConditionException $e) {
// ok, skip 'cause another worker did the same
}
--
Best regards,
Dmitrii Derepko.
@xepozz