Skip to content

Commit

Permalink
provide more descriptive exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Nov 3, 2023
1 parent 668ee4f commit 3ad6483
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private LogUtil() {}

/**
* Returns the global LogEntryDispatcher by using the available ILogEntryDispatcherFactory implementations loaded
* through ServiceLoaderand connects all known loggers to it.
* through ServiceLoader and connects all known loggers to it.
*
* @return The global LogEntryDispatcher instance.
* @throws ServiceConfigurationError if no factories can create a LogEntryDispatcher.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public ArgumentsParser(String name, String description, int minArgs, int maxArgs
this.name = Objects.requireNonNull(name);
this.description = Objects.requireNonNull(description);

LangUtil.check(minArgs >= 0);
LangUtil.check(maxArgs >= minArgs);
LangUtil.check(minArgs >= 0, "minimal number of arguments must not be negative: %s", minArgs);
LangUtil.check(maxArgs >= minArgs, "maximum number of arguments must be greater than or equal to the minimum number of arguments: %s (minimum number of arguments is %s", maxArgs, minArgs);
this.minPositionalArgs = minArgs;
this.maxPositionalArgs = maxArgs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void push(String name, Object value) {
*/
public void pop(String name) {
AttributeChange change = openedAttributes.pop();
LangUtil.check(name.equals(change.name()));
LangUtil.check(name.equals(change.name()), "name does not match: \"%s\", expected \"%s\"", name, change.name());
Map<String, Object> attributes = split();
if (change.previousValue() == null) {
attributes.remove(name);
Expand Down
2 changes: 1 addition & 1 deletion utility/src/main/java/com/dua3/utility/text/TextUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public static void transform(String template,

// determine ref name
int varEnd = template.indexOf(TRANSFORM_REF_END, pos);
LangUtil.check(varEnd != -1);
LangUtil.check(varEnd != -1, "unexpected end of template, '%s' expected", TRANSFORM_REF_END);
String varName = template.substring(pos, varEnd);
pos = varEnd + TRANSFORM_REF_END.length();

Expand Down

0 comments on commit 3ad6483

Please sign in to comment.