io.github.davidebocca.util.unit.test.exception.UnitTestException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unit-test Show documentation
Show all versions of unit-test Show documentation
Simple library to help developments of util tests
/**
*
*/
package io.github.davidebocca.util.unit.test.exception;
import java.text.MessageFormat;
import io.github.davidebocca.util.unit.test.utils.LoggingUtils;
/**
* @author cr10248
*
*/
public class UnitTestException extends Exception {
private static final long serialVersionUID = 1L;
public UnitTestException(ErrorCodeEnum errorCodeEnum) {
super(generateMessage(errorCodeEnum));
}
public UnitTestException(ErrorCodeEnum errorCodeEnum, String... extraParams) {
super(generateMessage(errorCodeEnum, extraParams));
}
public UnitTestException(ErrorCodeEnum errorCodeEnum, Throwable exception) {
super(generateMessage(errorCodeEnum), exception);
}
private static String generateMessage(ErrorCodeEnum errorCodeEnum) {
return MessageFormat.format("{0} - {1}", errorCodeEnum.getErrorCode(), errorCodeEnum.getErrorMessage());
}
private static String generateMessage(ErrorCodeEnum errorCodeEnum, String... extraParams) {
String message = generateMessage(errorCodeEnum);
return message.concat(LoggingUtils.getExtraParamsString(extraParams));
}
}