err

package
v0.0.0-...-7dcb666 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package err provides functionalities for error handling in a structured manner. It defines a custom error type 'Err' that encapsulates an error with a caller and a message. This package is designed to provide more context about where an error was thrown.

The Err struct contains two fields: 'caller' and 'message'. 'caller' represents the origin of the error, and 'message' provides details about the error.

There are three main methods associated with the Err struct: - New: creates a new instance of Err with the specified caller and an empty message. - Throwf: formats an error message according to a format specifier. - Throw: updates the message of the Err with the passed message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err struct {
	// contains filtered or unexported fields
}

Err is an exported type that encapsulates an error with a caller and a message.

func New

func New(caller string) *Err

New create new instance of Err with specified caller and an empty message. It returns the pointer to the created Err.

func (*Err) Error

func (e *Err) Error() string

Error returns a string that represents the Err. It combines the caller and the message of the Err.

func (*Err) Throw

func (e *Err) Throw(message string) *Err

Throw updates the error message with the passed message and returns the error.

func (*Err) Throwf

func (e *Err) Throwf(format string, a ...any) *Err

Throwf formats an error message according to a format specifier and returns the error. It updates the message of the Err with the formatted message.

Jump to

Keyboard shortcuts

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