ErrorInfo
interface ErrorInfo
Standardized interface for representing error information in API responses and operations.
This interface provides a consistent structure for error reporting across the application, enabling uniform error handling, logging, and client communication. It encapsulates error codes, human-readable messages, and detailed binding errors for comprehensive error reporting.
Key features:
Success/failure status determination
Structured error codes for programmatic handling
Localized error messages for user display
Detailed binding errors for validation failures
See also
for the default implementation
for objects that can provide error information
// Successful operation
val success = ErrorInfo.OK
assert(success.succeeded) // true
// Failed operation with details
val error = ErrorInfo.of(
errorCode = "VALIDATION_ERROR",
errorMsg = "Invalid input parameters",
bindingErrors = listOf(
BindingError("email", "Invalid email format"),
BindingError("age", "Must be positive number")
)
)Content copied to clipboard