Class ExceptionLocalizer
This class provides a method to convert a Throwable into a localized
string message based on its exception type. It uses a resource bundle named
"exceptions" with the Arabic locale to retrieve localized messages.
Note: This class cannot be instantiated. Attempting to instantiate
it will always throw a NaftahBugError.
- Author:
- Chakib Daii
-
Field Details
-
BUNDLE
-
-
Constructor Details
-
ExceptionLocalizer
private ExceptionLocalizer()Private constructor to prevent instantiation.Always throws a
NaftahBugErrorwith an Arabic message "استخدام غير مسموح به." ("Usage not allowed.") when called.
-
-
Method Details
-
localizeException
Localizes the message of the givenThrowable.Extracts the most specific cause of the exception, retrieves its simple class name as the key, and looks up the corresponding localized message from the resource bundle. If the key does not exist, a default message is used instead. The localized message is then formatted with the exception's localized message.
- Parameters:
e- the throwable to localize- Returns:
- the localized message string
-