Documentation
¶
Index ¶
Constants ¶
const ( INVALID_ARGUMENT = "INVALID_ARGUMENT" // Request contains invalid parameters INVALID_OPERATION = "INVALID_OPERATION" // Operation not permitted in current state UNKNOWN_ERROR = "UNKNOWN_ERROR" // Unexpected system error NOP = "NOP" // No operation performed NO_CONTENT = "NO_CONTENT" // Request processed but no content returned )
Standard failure message codes for consistent error handling.
Variables ¶
This section is empty.
Functions ¶
func IsKnownErrorCode ¶
IsKnownErrorCode validates if message follows standard error code format. Error codes must be 1-64 characters, uppercase letters, numbers, and underscores only.
func ThrowFailure ¶
func ThrowFailure(err error)
ThrowFailure converts an error to structured Failure and panics with it. Automatically categorizes errors based on type and message format.
func ThrowFailureMessage ¶
func ThrowFailureMessage(message, reason string)
ThrowFailureMessage creates a Failure with custom message and reason, then panics. Validates message format and provides consistent error structure.
Types ¶
type Failure ¶
type Failure struct {
Err error `json:"-"`
Message string `json:"message"`
Description string `json:"description,omitempty"`
TraceID string `json:"_trace_id,omitempty"`
Reason json.RawMessage `json:"reason,omitempty"`
Timestamp int64 `json:"timestamp"`
}
Failure represents a structured error response with context and tracing support. Provides JSON serialization and error chain unwrapping capabilities.
func (*Failure) MarshalJSON ¶
MarshalJSON provides custom JSON serialization for proper API response format.
type WellKnownError ¶
type WellKnownError interface {
error
GetMessage() string
GetDescription() string
GetReason() json.RawMessage
}
WellKnownError defines interface for structured error types. Provides standardized error information extraction methods.