From 1e7e019d256d69bf5743f82a68853a77c0fa44c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Mon, 17 Feb 2020 16:01:11 +0100 Subject: [PATCH] Supply arguments in flag parse exceptions --- .../plotsquared/plot/flags/FlagParseException.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java index 29ea1d334..cfb9f5180 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flags/FlagParseException.java @@ -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; } + }