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 Details

    • getMessage

      String getMessage(String code, Object[] args)
      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 code
      args - The arguments for message formats.
      Returns:
      The created message
    • getLocalizedMessage

      String getLocalizedMessage(String code, Object[] args, Locale locale)
      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 is null the locale provided of the current RequestContext is used
      Parameters:
      code - The used code
      args - The arguments for message formats.
      locale - The locale
      Returns:
      The created message
    • getMessageTarget

      MessageTarget getMessageTarget(String target)
      Creates a new MessageTarget 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 new MessageTarget with a target, based on a target parameter and a CQN path.
      Parameters:
      parameter - target parameter serving as the entry point for the path resolution
      path - 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 new MessageTarget 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 resolution
      type - 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)
      Creates a new MessageTarget with a target, based on a Path and CdsElement.
      Parameters:
      path - the cqn path to the targeted cds element
      element - the targeted element
      Returns:
      the MessageTarget
    • getErrorsProperties

      CdsProperties.Errors getErrorsProperties()
      Returns:
      the active CdsProperties.Errors properties