of
fun of(errorCode: String, errorMsg: String? = null, bindingErrors: List<BindingError> = emptyList()): DefaultErrorInfo
Creates a new ErrorInfo instance with the specified parameters.
This factory method provides a convenient way to create error information instances without directly instantiating DefaultErrorInfo. It handles null error messages by converting them to empty strings.
Return
A new DefaultErrorInfo instance with the specified error details
val validationError = ErrorInfo.of(
errorCode = "VALIDATION_FAILED",
errorMsg = "Input validation failed",
bindingErrors = listOf(
BindingError("username", "Username is required"),
BindingError("email", "Invalid email format")
)
)Content copied to clipboard
Parameters
errorCode
The error code that identifies the type of error (must not be null)
errorMsg
An optional human-readable error message (defaults to empty string if null)
bindingErrors
A list of field-level binding errors (defaults to empty list)