Browse Source

Add constructors with varargs in PippoException

pull/95/merge
Decebal Suiu 8 years ago
parent
commit
5279f74095
  1. 10
      pf4j/src/main/java/ro/fortsoft/pf4j/PluginException.java
  2. 9
      pf4j/src/main/java/ro/fortsoft/pf4j/util/StringUtils.java

10
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));
}
}

9
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);
}
}

Loading…
Cancel
Save