mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 18:24:43 +02:00
Supply arguments in flag parse exceptions
This commit is contained in:
@ -1,19 +1,21 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flags;
|
package com.github.intellectualsites.plotsquared.plot.flags;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
import com.github.intellectualsites.plotsquared.plot.config.Caption;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.CaptionUtility;
|
||||||
|
|
||||||
public class FlagParseException extends Exception {
|
public class FlagParseException extends Exception {
|
||||||
|
|
||||||
private final PlotFlag<?, ?> flag;
|
private final PlotFlag<?, ?> flag;
|
||||||
private final String value;
|
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.",
|
super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.",
|
||||||
flag.getName(), value));
|
flag.getName(), value));
|
||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.errorMessage = errorMessage;
|
this.errorMessage = CaptionUtility.format(errorMessage, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,8 @@ public class FlagParseException extends Exception {
|
|||||||
return this.flag;
|
return this.flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Caption getErrorMessage() {
|
public String getErrorMessage() {
|
||||||
return errorMessage;
|
return errorMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user