All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.xlrit.gears.base.util.ErrorUtils Maven / Gradle / Ivy

There is a newer version: 1.17.5
Show newest version
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));
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy