errors

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Deprecated: errors is deprecated and has been moved to github.com/neticdk/go-common/pkg/cli/cmd

It has been deprecated due to the fact that it conflicts with the standard library errors package. Please use directly from cmd package instead. Expect the errors package to be removed in later versions.

Deprecated: errors is deprecated and has been moved to github.com/go-common/pkg/cli/cmd

It has been deprecated due to the fact that it conflicts with the standard library errors package. Please use directly from cmd package instead. Expect the errors package to be removed in later versions.

Deprecated: errors is deprecated and has been moved to github.com/go-common/pkg/cli/cmd

It has been deprecated due to the fact that it conflicts with the standard library errors package. Please use directly from cmd package instead. Expect the errors package to be removed in later versions.

Deprecated: errors is deprecated and has been moved to github.com/go-common/pkg/cli/cmd

It has been deprecated due to the fact that it conflicts with the standard library errors package. Please use directly from cmd package instead. Expect the errors package to be removed in later versions.

Index

Constants

View Source
const DefaultWrapWidth = 80

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultHandler deprecated

type DefaultHandler struct {
	Output io.Writer
	// contains filtered or unexported fields
}

Handler handles errors providing colored output to a specified writer (defaults to stderr).

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func NewDefaultHandler deprecated

func NewDefaultHandler(output io.Writer) *DefaultHandler

NewDefaultHandler creates a new DefaultErrorHandler with the specified output writer. If no writer is provided, it defaults to stderr.

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*DefaultHandler) HandleError deprecated

func (h *DefaultHandler) HandleError(err error)

HandleError checks if the given error implements the ErrorWithHelp interface. If it does, it prints the error message and help message in a colored format to the configured output writer. Otherwise, it prints a generic error message.

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*DefaultHandler) NewGeneralError deprecated

func (h *DefaultHandler) NewGeneralError(message, helpMsg string, err error, code int) *GeneralError

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*DefaultHandler) SetWrap deprecated added in v0.8.7

func (h *DefaultHandler) SetWrap(wrap bool)

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*DefaultHandler) SetWrapWidth deprecated added in v0.8.7

func (h *DefaultHandler) SetWrapWidth(width int)

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

type ErrorWithHelp deprecated

type ErrorWithHelp interface {
	error

	// Help returns a help message for the error
	Help() string

	// Unwrap returns the underlying error
	Unwrap() error // Optional: for wrapped errors

	// Code returns the error code
	Code() int // Optional: for error codes
}

ErrorWithHelp interface is used for errors that can provide help

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

type GeneralError deprecated

type GeneralError struct {
	Message string
	HelpMsg string
	CodeVal int
	Err     error
}

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*GeneralError) Code deprecated

func (e *GeneralError) Code() int

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*GeneralError) Error deprecated

func (e *GeneralError) Error() string

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*GeneralError) Help deprecated

func (e *GeneralError) Help() string

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*GeneralError) Unwrap deprecated

func (e *GeneralError) Unwrap() error

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

type Handler deprecated

type Handler interface {
	// HandleError handles the given error.
	HandleError(err error)
	// NewGeneralError creates a new GeneralError with the specified message, help message, error, and code.
	NewGeneralError(message, helpMsg string, err error, code int) *GeneralError
	// SetWrap sets whether to wrap the error message and help message.
	SetWrap(wrap bool)
	// SetWrapWidth sets the width to wrap the error message and help message.
	SetWrapWidth(width int)
}

Handler is an interface for handling errors.

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

type InvalidArgumentError deprecated

type InvalidArgumentError struct {
	Flag     string
	Val      string
	OneOf    []string
	SeeOther string
	Context  string
}

InvalidArgumentError is returned when an argument is invalid

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*InvalidArgumentError) Code deprecated

func (e *InvalidArgumentError) Code() int

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*InvalidArgumentError) Error deprecated

func (e *InvalidArgumentError) Error() string

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*InvalidArgumentError) Help deprecated

func (e *InvalidArgumentError) Help() string

Help returns the error message

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

func (*InvalidArgumentError) Unwrap deprecated

func (e *InvalidArgumentError) Unwrap() error

Deprecated: use github.com/neticdk/go-common/pkg/cli/cmd instead.

Jump to

Keyboard shortcuts

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