Documentation
¶
Overview ¶
Copyright (c) 2025 Nexlayer. All rights reserved.n// Use of this source code is governed by an MIT-stylen// license that can be found in the LICENSE file.nn Package errors provides standardized error types and utilities for the Nexlayer CLI.
Index ¶
- func As(err error, target interface{}) bool
- func IsErrorType(err error, errType ErrorType) bool
- type Error
- func InternalError(message string, cause error) *Error
- func NetworkError(message string, cause error) *Error
- func New(errType ErrorType, message string) *Error
- func NewInvalidNameError(name, field string) *Error
- func NewInvalidPortError(port interface{}, message string) *Error
- func NewInvalidVolumeError(volume, reason string) *Error
- func NewMissingImageError(podName string) *Error
- func NewUnsupportedOSError(os string) *Error
- func Newf(errType ErrorType, format string, args ...interface{}) *Error
- func SystemError(message string, cause error) *Error
- func UserError(message string, cause error) *Error
- func Wrap(err error, errType ErrorType, message string) *Error
- func Wrapf(err error, errType ErrorType, format string, args ...interface{}) *Error
- type ErrorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsErrorType ¶
IsErrorType checks if an error is of a specific type
Types ¶
type Error ¶
type Error struct {
Cause error `json:"-"`
Details map[string]interface{} `json:"details,omitempty"`
Type ErrorType `json:"type"`
Message string `json:"message"`
Code string `json:"code,omitempty"`
Field string `json:"field,omitempty"`
}
Error represents a structured error with context
func InternalError ¶
InternalError creates a new internal error
func NetworkError ¶
NetworkError creates a new network error
func NewInvalidNameError ¶
NewInvalidNameError creates a new invalid name error
func NewInvalidPortError ¶
NewInvalidPortError creates a new invalid port error
func NewInvalidVolumeError ¶
NewInvalidVolumeError creates a new invalid volume error
func NewMissingImageError ¶
NewMissingImageError creates a new missing image error
func NewUnsupportedOSError ¶
NewUnsupportedOSError creates a new unsupported OS error
func SystemError ¶
SystemError creates a new system error
func (*Error) WithDetails ¶
WithDetails adds additional context to the error
type ErrorType ¶
type ErrorType string
ErrorType represents the type of error
const ( // Common error types ErrorTypeInput ErrorType = "input_error" ErrorTypeValidation ErrorType = "validation_error" ErrorTypeNetwork ErrorType = "network_error" ErrorTypePermission ErrorType = "permission_error" ErrorTypeConfig ErrorType = "config_error" ErrorTypeInternal ErrorType = "internal_error" ErrorTypeUnknown ErrorType = "unknown_error" // Specific error types ErrorTypeInvalidPort ErrorType = "invalid_port" ErrorTypeMissingImage ErrorType = "missing_image" ErrorTypeInvalidVolume ErrorType = "invalid_volume" ErrorTypeInvalidName ErrorType = "invalid_name" ErrorTypeUnsupportedOS ErrorType = "unsupported_os" )
func ErrorTypeFromString ¶
ErrorTypeFromString converts a string to an ErrorType