errors

package
v0.1.0-alpha.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 4 Imported by: 0

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 defines an error type for handling deployment errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeploymentError

type DeploymentError struct {
	Message   string
	Cause     error
	ErrorType string
	Context   *ValidationContext
}

DeploymentError represents an error that occurred during deployment

func NewDeploymentError

func NewDeploymentError(message string, cause error) *DeploymentError

NewDeploymentError creates a new deployment error

func NewValidationError

func NewValidationError(message string, context *ValidationContext) *DeploymentError

NewValidationError creates a new validation error with structured context

func (*DeploymentError) Error

func (e *DeploymentError) Error() string

Error returns the error message

func (*DeploymentError) Is

func (e *DeploymentError) Is(target error) bool

Is reports whether the target matches this error

func (*DeploymentError) MarshalJSON

func (e *DeploymentError) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*DeploymentError) Unwrap

func (e *DeploymentError) Unwrap() error

Unwrap returns the underlying error

type Error

type Error struct {
	Type    ErrorType `json:"type"`
	Message string    `json:"message"`
	Cause   error     `json:"cause,omitempty"`
	File    string    `json:"file,omitempty"`
	Line    int       `json:"line,omitempty"`
	Stack   []string  `json:"stack,omitempty"`
}

Error represents a structured error with context

func InternalError

func InternalError(message string, cause error) *Error

InternalError creates a new internal error

func NetworkError

func NetworkError(message string, cause error) *Error

NetworkError creates a new network error

func NewError

func NewError(errType ErrorType, message string, cause error) *Error

NewError creates a new error with context

func SystemError

func SystemError(message string, cause error) *Error

SystemError creates a new system error

func UserError

func UserError(message string, cause error) *Error

UserError creates a new user error

func (*Error) Error

func (e *Error) Error() string

type ErrorType

type ErrorType int

ErrorType represents the category of error

const (
	// ErrorTypeUser represents user-caused errors (invalid input, etc.)
	ErrorTypeUser ErrorType = iota
	// ErrorTypeSystem represents system-level errors (IO, permissions, etc.)
	ErrorTypeSystem
	// ErrorTypeNetwork represents network-related errors
	ErrorTypeNetwork
	// ErrorTypeInternal represents internal application errors
	ErrorTypeInternal
)

func (ErrorType) String

func (et ErrorType) String() string

String returns the string representation of the error type

type ValidationContext

type ValidationContext struct {
	Field           string   `json:"field,omitempty"`            // The field that failed validation
	ExpectedType    string   `json:"expected_type,omitempty"`    // Expected type/format
	ActualValue     string   `json:"actual_value,omitempty"`     // Actual value received
	MissingVar      string   `json:"missing_var,omitempty"`      // Name of missing environment variable
	AllowedValues   []string `json:"allowed_values,omitempty"`   // List of allowed values
	ResolutionHints []string `json:"resolution_hints,omitempty"` // Hints for fixing the error
	Example         string   `json:"example,omitempty"`          // Example of correct usage
}

ValidationContext contains structured information about a validation error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL