Class IntegrationApiExceptionTranslationHandler
java.lang.Object
de.hybris.platform.integrationbackoffice.exceptionhandlers.IntegrationApiExceptionTranslationHandler
- All Implemented Interfaces:
com.hybris.cockpitng.service.ExceptionTranslationHandler,org.springframework.core.Ordered
- Direct Known Subclasses:
IntegrationBackofficeExceptionTranslationHandler,OutboundSyncBackofficeExceptionTranslationHandler,WebhookExceptionTranslationHandler
public abstract class IntegrationApiExceptionTranslationHandler
extends Object
implements com.hybris.cockpitng.service.ExceptionTranslationHandler, org.springframework.core.Ordered
An abstract class for translating target exceptions to localized error messages. Its subclass needs to overwrite methods in
order to specify the target exceptions. Target exceptions are those that can be handled even if they caused some other exception.
For example, if
targetException is an exception known by the handler and there is another exception, e.g.
var ex = new Throwable(targetException), then the root cause(s) of the ex will be analyzed and when
targetException is found, the message will be displayed for the targetException instead of the ex.
The message is retrieved from the localization properties of this extension by the resource bundle key that has the following
format: <prefix>.exceptionTranslation.msg.<exception_simple_class_name>
<prefix> is the resource
bundle prefix used by the handler or by the extension in general (for all messagges and not only for exception translation).-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanprotected StringconvertExceptionToResourceMsg(Throwable exception) Try to get bundle resource with the information of the exception that is being handled.protected Object[]extractParameters(Throwable exception) Extracts parameters from the given exception.protected abstract StringRetrieves prefix of all property keys in the resource bundle used by this extension/handler.intgetOrder()protected abstract Collection<Class<? extends Throwable>>voidInjects localization service implementation to be used for localized message retrieval from the localization resource bundle.
-
Constructor Details
-
IntegrationApiExceptionTranslationHandler
public IntegrationApiExceptionTranslationHandler()
-
-
Method Details
-
canHandle
- Specified by:
canHandlein interfacecom.hybris.cockpitng.service.ExceptionTranslationHandler
-
toString
- Specified by:
toStringin interfacecom.hybris.cockpitng.service.ExceptionTranslationHandler
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
getTargetedExceptions
-
convertExceptionToResourceMsg
Try to get bundle resource with the information of the exception that is being handled.- Parameters:
exception- The exception that is being translated. Use its class name or other information as key to get bundle resource
-
extractParameters
Extracts parameters from the given exception.- Parameters:
exception- an exception to convert to a parameters array.- Returns:
- the parameters array that will be used to format the localized message or an empty array, if the message for the exception should not have parameters.
-
getKeyPrefix
Retrieves prefix of all property keys in the resource bundle used by this extension/handler. All localization keys should start with this prefix, then followed by"."and further key specification.- Returns:
- a prefix to be used for localization property keys in the resource bundle.
-
setLocalizationService
Injects localization service implementation to be used for localized message retrieval from the localization resource bundle.- Parameters:
service- a localization service implementation. Ifnull, then a default service available in the platform will be used.
-