Class ErrorMessageBuilder


  • public class ErrorMessageBuilder
    extends Object
    Builder for Exasol error messages.
    • Method Detail

      • message

        public ErrorMessageBuilder message​(String message,
                                           Object... arguments)
        Format a given message pattern with placeholders, filling them with the arguments passed in the specified form.

        Placeholders are defined in the message pattern by using double curly brackets {{}}. By default, arguments are formatted with simple quotes unless specified other wise with the 'unquoted' format, defined by {{|uq}}.

        You should always define names in the placeholders. This name will be shown in case no argument is missing, by {{argumentName}} or {{argumentName|uq}}.

        Below you can find examples on how to use it.

        Example for quoted arguments:

        ErrorMessageBuilder("ERROR_CODE").message("Message with {{namedQuotedArgument}}, {{}} and {{missingQuotedArgument}}, "named", "unnamed")

        returns "ERROR_CODE: Message with 'named', 'unnamed' and UNKNOWN PLACEHOLDER('anotherQuotedArgument')".

        Example for unquoted arguments:

        ErrorMessageBuilder("ERROR_CODE").message("Message with {{namedUnquotedArgument|uq}}, {{|uq}} and {{missingUnquotedArgument|uq}}, "named", "unnamed")

        returns "ERROR_CODE: Message with named, unnamed and UNKNOWN PLACEHOLDER('anotherQuotedArgument')".

        Parameters:
        message - message that may contain placeholders
        arguments - arguments to fill the placeholders
        Returns:
        self for fluent programming
      • parameter

        public ErrorMessageBuilder parameter​(String placeholder,
                                             Object value)
        Add a parameter. This method quotes the parameter.

        You can use the parameter in message and mitigation using {{parameter}}.

        Parameters:
        placeholder - placeholder without parentheses
        value - value to insert
        Returns:
        self for fluent programming
      • parameter

        public ErrorMessageBuilder parameter​(String placeholder,
                                             Object value,
                                             String description)
        Add a parameter.

        You can use the parameter in message and mitigation using {{parameter}}.

        Parameters:
        placeholder - placeholder without parentheses
        value - value to insert
        description - description for the error catalog
        Returns:
        self for fluent programming
      • unquotedParameter

        @Deprecated(since="3.0.0",
                    forRemoval=true)
        public ErrorMessageBuilder unquotedParameter​(String placeholder,
                                                     Object value)
        Deprecated, for removal: This API element is subject to removal in a future version.
        As of release 3.0.0
        Add a parameter without quotes.

        This method is deprecated. You can define that a parameter is unquoted by adding '|uq' to its correspondent placeholder. For more information, see message(String, Object...).

        Parameters:
        placeholder - placeholder without parentheses
        value - value to insert
        Returns:
        self for fluent programming
      • unquotedParameter

        @Deprecated(since="3.0.0",
                    forRemoval=true)
        public ErrorMessageBuilder unquotedParameter​(String placeholder,
                                                     Object value,
                                                     String description)
        Deprecated, for removal: This API element is subject to removal in a future version.
        As of release 3.0.0
        Add a parameter without quotes.

        This method is deprecated. You can define that a parameter is unquoted by adding '|uq' to its correspondent placeholder. For more information, see message(String, Object...).

        Parameters:
        placeholder - placeholder without parentheses
        value - value to insert
        description - description for the error catalog
        Returns:
        self for fluent programming
      • mitigation

        public ErrorMessageBuilder mitigation​(String mitigation,
                                              Object... arguments)
        Add a mitigation. Explain here what users can do to resolve or avoid this error.

        For learning about the format rules, see message(String, Object...).

        Parameters:
        mitigation - mitigation message that may contain placeholders
        arguments - arguments to fill the placeholders
        Returns:
        self for fluent programming
      • ticketMitigation

        public ErrorMessageBuilder ticketMitigation()
        Add a mitigation for cases in which the only thing a user can do is opening a ticket.
        Returns:
        self for fluent programming
      • toString

        public String toString()
        Build the error message.
        Overrides:
        toString in class Object
        Returns:
        built error massage string