Supply arguments in flag parse exceptions

This commit is contained in:
Alexander Söderberg 2020-02-17 16:01:11 +01:00
parent 6c070b4c23
commit 1e7e019d25

View File

@ -1,19 +1,21 @@
package com.github.intellectualsites.plotsquared.plot.flags;
import com.github.intellectualsites.plotsquared.plot.config.Caption;
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
public class FlagParseException extends Exception {
private final PlotFlag<?, ?> flag;
private final String value;
private final Caption errorMessage;
private final String errorMessage;
public FlagParseException(final PlotFlag<?, ?> flag, final String value, final Caption errorMessage) {
public FlagParseException(final PlotFlag<?, ?> flag, final String value, final Caption errorMessage,
final Object ... args) {
super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.",
flag.getName(), value));
this.flag = flag;
this.value = value;
this.errorMessage = errorMessage;
this.errorMessage = CaptionUtility.format(errorMessage, args);
}
/**
@ -34,7 +36,8 @@ public class FlagParseException extends Exception {
return this.flag;
}
public Caption getErrorMessage() {
public String getErrorMessage() {
return errorMessage;
}
}