public class ErrorMessageBuilder extends Object
| Modifier and Type | Method and Description |
|---|---|
ErrorMessageBuilder |
message(String message,
Object... arguments)
Format a given message pattern with placeholders, filling them with the arguments passed in the specified form.
|
ErrorMessageBuilder |
mitigation(String mitigation,
Object... arguments)
Add a mitigation.
|
ErrorMessageBuilder |
parameter(String placeholder,
Object value)
Add a parameter.
|
ErrorMessageBuilder |
parameter(String placeholder,
Object value,
String description)
Add a parameter.
|
ErrorMessageBuilder |
ticketMitigation()
Add a mitigation for cases in which the only thing a user can do is opening a ticket.
|
String |
toString()
Build the error message.
|
ErrorMessageBuilder |
unquotedParameter(String placeholder,
Object value)
Deprecated.
since
3.0.0, set for removal |
ErrorMessageBuilder |
unquotedParameter(String placeholder,
Object value,
String description)
Deprecated.
since
3.0.0, set for removal |
public ErrorMessageBuilder message(String message, Object... arguments)
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')".
message - message that may contain placeholdersarguments - arguments to fill the placeholderspublic ErrorMessageBuilder parameter(String placeholder, Object value)
You can use the parameter in message and mitigation using {{parameter}}.
placeholder - placeholder without parenthesesvalue - value to insertpublic ErrorMessageBuilder parameter(String placeholder, Object value, String description)
You can use the parameter in message and mitigation using {{parameter}}.
placeholder - placeholder without parenthesesvalue - value to insertdescription - description for the error catalog@Deprecated public ErrorMessageBuilder unquotedParameter(String placeholder, Object value)
3.0.0, set for removal
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...).
placeholder - placeholder without parenthesesvalue - value to insert@Deprecated public ErrorMessageBuilder unquotedParameter(String placeholder, Object value, String description)
3.0.0, set for removal
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...).
placeholder - placeholder without parenthesesvalue - value to insertdescription - description for the error catalogpublic ErrorMessageBuilder mitigation(String mitigation, Object... arguments)
For learning about the format rules, see message(String, Object...).
mitigation - mitigation message that may contain placeholdersarguments - arguments to fill the placeholderspublic ErrorMessageBuilder ticketMitigation()
Copyright © 2021. All rights reserved.