com.xlrit.gears.base.util.ErrorUtils Maven / Gradle / Ivy
package com.xlrit.gears.base.util;
import static com.xlrit.gears.base.util.StringUtils.toSnakeCase;
public class ErrorUtils {
public static String inputErrorMsg(T value, String methodName, String returnTypeName) {
return String.format("Input '%s' of function %s cannot be converted to %s.", value, methodName, returnTypeName);
}
public static IllegalArgumentException inputError(T value, String functionName, String returnTypeName, Exception e) {
return new IllegalArgumentException(inputErrorMsg(value, toSnakeCase(functionName), returnTypeName), e);
}
public static IllegalArgumentException inputError(T value, String functionName, String returnTypeName) {
return new IllegalArgumentException(inputErrorMsg(value, toSnakeCase(functionName), returnTypeName));
}
public static IllegalArgumentException languageError(String functionName, String language) {
return new IllegalArgumentException(String.format("Function %s does not support language '%s'.", toSnakeCase(functionName), language));
}
}