From 393db271b2b27125c49c5d25acac5487cdb34e86 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Fri, 1 Sep 2023 15:07:52 +0200 Subject: [PATCH] Document try/catch in native enum conversion --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0e1a4187..d555b2c2 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,8 @@ Review and validate the code changes for missed edge cases: - `Enum::coerce()`: If only values were passed, you can replace it with `tryFrom()`. If keys or instances could also be passed, you might need additional logic to cover this. - `Enum::$description` and `Enum::getDescription()`: Implement an alternative. +- try/catch-blocks that handle `BenSampo\Enum\Exceptions\InvalidEnumKeyException` or `BenSampo\Enum\Exceptions\InvalidEnumMemberException`. + Either catch the `ValueError` thrown by native enums, or switch to using `tryFrom()` and handle `null`. Once all enums are converted, you can remove your dependency on this library.