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")
)
)

Inheritors

Types

Link copied to clipboard
object Companion

Companion object providing constants and utility functions for working with ErrorInfo instances.

Properties

Link copied to clipboard

A list of detailed binding errors that occurred during data validation or mapping.

Link copied to clipboard
abstract val errorCode: String

The error code that uniquely identifies the type of error.

Link copied to clipboard
abstract val errorMsg: String

A human-readable message describing the error.

Link copied to clipboard
open val succeeded: Boolean

Indicates whether the operation was successful.

Functions

Link copied to clipboard

Converts this ErrorInfo to a materialized instance for serialization.

Link copied to clipboard

Converts this ErrorInfo to a DefaultErrorInfo instance.