errors

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides structured error handling for Nebula

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRetryable

func IsRetryable(err error) bool

IsRetryable returns true if the error is retryable

func IsType

func IsType(err error, errType ErrorType) bool

IsType checks if the error is of the given type

Types

type Error

type Error struct {
	Type    ErrorType
	Message string
	Cause   error
	Details map[string]interface{}
	Stack   []StackFrame
}

Error represents a structured error with context

func New

func New(errType ErrorType, message string) *Error

New creates a new error with the given type and message

func Wrap

func Wrap(err error, errType ErrorType, message string) *Error

Wrap wraps an existing error with additional context

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error

func (*Error) WithDetail

func (e *Error) WithDetail(key string, value interface{}) *Error

WithDetail adds a key-value detail to the error

type ErrorType

type ErrorType string

ErrorType represents the category of error

const (
	// ErrorTypeInternal represents internal system errors
	ErrorTypeInternal ErrorType = "internal"
	// ErrorTypeValidation represents validation errors
	ErrorTypeValidation ErrorType = "validation"
	// ErrorTypeNotFound represents resource not found errors
	ErrorTypeNotFound ErrorType = "not_found"
	// ErrorTypeConflict represents conflict errors
	ErrorTypeConflict ErrorType = "conflict"
	// ErrorTypeRateLimit represents rate limit errors
	ErrorTypeRateLimit ErrorType = "rate_limit"
	// ErrorTypeTimeout represents timeout errors
	ErrorTypeTimeout ErrorType = "timeout"
	// ErrorTypeConnection represents connection errors
	ErrorTypeConnection ErrorType = "connection"
	// ErrorTypeAuthentication represents authentication errors
	ErrorTypeAuthentication ErrorType = "authentication"
	// ErrorTypePermission represents permission errors
	ErrorTypePermission ErrorType = "permission"
	// ErrorTypeConfig represents configuration errors
	ErrorTypeConfig ErrorType = "config"
	// ErrorTypeData represents data processing errors
	ErrorTypeData ErrorType = "data"
	// ErrorTypeCapability represents capability/feature not supported errors
	ErrorTypeCapability ErrorType = "capability"
	// ErrorTypeHealth represents health check errors
	ErrorTypeHealth ErrorType = "health"
	// ErrorTypeFile represents file operation errors
	ErrorTypeFile ErrorType = "file"
	// ErrorTypeQuery represents query execution errors
	ErrorTypeQuery ErrorType = "query"
)

type StackFrame

type StackFrame struct {
	Function string
	File     string
	Line     int
}

StackFrame represents a single frame in the call stack

Jump to

Keyboard shortcuts

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