fix junit

This commit is contained in:
Anthony Stirling 2025-07-02 16:33:27 +01:00
parent a6fee5e90f
commit 9ebb4a3c31
2 changed files with 6 additions and 8 deletions

View File

@ -1,6 +1,7 @@
package stirling.software.common.util;
import java.io.IOException;
import java.text.MessageFormat;
import lombok.extern.slf4j.Slf4j;
@ -104,7 +105,7 @@ public class ExceptionUtils {
*/
public static IOException createIOException(
String messageKey, String defaultMessage, Exception cause, Object... args) {
String message = String.format(defaultMessage, args);
String message = MessageFormat.format(defaultMessage, args);
return new IOException(message, cause);
}
@ -119,7 +120,7 @@ public class ExceptionUtils {
*/
public static RuntimeException createRuntimeException(
String messageKey, String defaultMessage, Exception cause, Object... args) {
String message = String.format(defaultMessage, args);
String message = MessageFormat.format(defaultMessage, args);
return new RuntimeException(message, cause);
}
@ -133,7 +134,7 @@ public class ExceptionUtils {
*/
public static IllegalArgumentException createIllegalArgumentException(
String messageKey, String defaultMessage, Object... args) {
String message = String.format(defaultMessage, args);
String message = MessageFormat.format(defaultMessage, args);
return new IllegalArgumentException(message);
}

View File

@ -56,11 +56,8 @@ public class ConvertWebsiteToPDF {
}
// Validate the URL format
if (!URL.matches("^https?://.*") || !GeneralUtils.isValidURL(URL)) {
throw ExceptionUtils.createIllegalArgumentException(
"error.invalidFormat",
"Invalid {0} format: {1}",
"URL",
"provided format is invalid");
throw ExceptionUtils.createInvalidArgumentException(
"URL", "provided format is invalid");
}
// validate the URL is reachable