Package com.sap.cds.services
Interface ServiceExceptionUtils
public interface ServiceExceptionUtils
Helper methods for creating (localized) messages in
ServiceException
.
ServiceExceptionUtils#getMessage
is used to implement ServiceException#getMessage
and
ServiceExceptionUtils#getLocalizedMessage
is used to implement ServiceException#getLocalizedMessage
respectively.
-
Method Summary
Modifier and TypeMethodDescriptiongetLocalizedMessage
(String code, Object[] args, Locale locale) Creates a message based on code and args.getMessage
(String code, Object[] args) Creates a message based on code and args.getMessageTarget
(com.sap.cds.ql.cqn.Path path, com.sap.cds.reflect.CdsElement element) getMessageTarget
(String target) Creates a newMessageTarget
with a string-based target<E extends com.sap.cds.ql.StructuredType<E>>
MessageTargetgetMessageTarget
(String parameter, Class<E> type, Function<E, Object> path) Creates a newMessageTarget
with a target, based on a target parameter and a CQN path.getMessageTarget
(String parameter, Function<com.sap.cds.ql.StructuredType<?>, Object> path) Creates a newMessageTarget
with a target, based on a target parameter and a CQN path.
-
Method Details
-
getMessage
Creates a message based on code and args.code
may either be a SL4J-message format or a bundle key. The JVM's default locale is taken to lookup code in resource bundles.- Parameters:
code
- The used codeargs
- The arguments for message formats.- Returns:
- The created message
-
getLocalizedMessage
Creates a message based on code and args.code
may either be a SL4J-message format or a bundle key. The specified locale is taken to lookup the code in resource bundles. If the specified locale isnull
the locale provided of the currentRequestContext
is used- Parameters:
code
- The used codeargs
- The arguments for message formats.locale
- The locale- Returns:
- The created message
-
getMessageTarget
Creates a newMessageTarget
with a string-based target- Parameters:
target
- the string-based target- Returns:
- the
MessageTarget
-
getMessageTarget
MessageTarget getMessageTarget(String parameter, Function<com.sap.cds.ql.StructuredType<?>, Object> path) Creates a newMessageTarget
with a target, based on a target parameter and a CQN path.- Parameters:
parameter
- target parameter serving as the entry point for the path resolutionpath
- the path to the target- Returns:
- the
MessageTarget
-
getMessageTarget
<E extends com.sap.cds.ql.StructuredType<E>> MessageTarget getMessageTarget(String parameter, Class<E> type, Function<E, Object> path) Creates a newMessageTarget
with a target, based on a target parameter and a CQN path.- Type Parameters:
E
- the entity type- Parameters:
parameter
- target parameter serving as the entry point for the path resolutiontype
- the root type of the path. Either an entity or a structured type.path
- the path to the target- Returns:
- the
MessageTarget
-
getMessageTarget
MessageTarget getMessageTarget(com.sap.cds.ql.cqn.Path path, com.sap.cds.reflect.CdsElement element) - Parameters:
path
- the cqn path to the targeted cds elementelement
- the targeted element- Returns:
- the
MessageTarget
-
getErrorsProperties
CdsProperties.Errors getErrorsProperties()- Returns:
- the active
CdsProperties.Errors
properties
-