From d6cb1ba6ae6abd118ec8094b420f9109594f420b Mon Sep 17 00:00:00 2001 From: Gaurav Date: Tue, 15 Mar 2022 17:03:57 +0530 Subject: [PATCH] update: add dedicated exception class --- src/Exceptions/CannotExtractCurrencyException.php | 15 +++++++++++++++ src/PriceFormatter.php | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/Exceptions/CannotExtractCurrencyException.php diff --git a/src/Exceptions/CannotExtractCurrencyException.php b/src/Exceptions/CannotExtractCurrencyException.php new file mode 100644 index 0000000..74a92fe --- /dev/null +++ b/src/Exceptions/CannotExtractCurrencyException.php @@ -0,0 +1,15 @@ +suffix()) ) { if ($possibleCurrency) { - throw new \Exception('Multiple currencies are using the same prefix and suffix. Please specify the currency of the formatted string.'); + throw new CannotExtractCurrencyException('Multiple currencies are using the same prefix and suffix. Please specify the currency of the formatted string.'); } $possibleCurrency = $currency; } } - return $possibleCurrency ?? throw new \Exception('None of the currencies are using the prefix and suffix that would match with the formatted string.'); + return $possibleCurrency ?? throw new CannotExtractCurrencyException('None of the currencies are using the prefix and suffix that would match with the formatted string.'); } }