diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2017-04-20 20:16:48 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2017-04-20 20:16:48 +0300 |
commit | 5279f74095dfb533d9c8e12d085877285b619280 (patch) | |
tree | 2565e1e8165ee9a497508a4552d7593f82b672c6 /pf4j/src | |
parent | d20ed779decb74ce55942358da52652160d3bbc0 (diff) | |
download | pf4j-5279f74095dfb533d9c8e12d085877285b619280.tar.gz pf4j-5279f74095dfb533d9c8e12d085877285b619280.zip |
Add constructors with varargs in PippoException
Diffstat (limited to 'pf4j/src')
-rw-r--r-- | pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java | 10 | ||||
-rw-r--r-- | pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java index 1de6079..caa194a 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java @@ -15,6 +15,8 @@ */ package ro.fortsoft.pf4j; +import ro.fortsoft.pf4j.util.StringUtils; + /** * An exception used to indicate that a plugin problem occurred. * @@ -40,4 +42,12 @@ public class PluginException extends Exception { super(message, cause); } + public PluginException(Throwable cause, String message, Object... args) { + super(StringUtils.format(message, args), cause); + } + + public PluginException(String message, Object... args) { + super(StringUtils.format(message, args)); + } + } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java b/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java index 6096086..62afecc 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java @@ -28,4 +28,13 @@ public class StringUtils { return !isEmpty(str); } + /** + * Format the string. Replace "{}" with %s and format the string using {@link String#format(String, Object...)}. + */ + public static String format(String str, Object... args) { + str = str.replaceAll("\\{}", "%s"); + + return String.format(str, args); + } + } |