errutil

package
v0.0.0-...-2c87074 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Unlicense Imports: 5 Imported by: 26

Documentation

Overview

Package errutil implements some error utility functions.

Index

Examples

Constants

This section is empty.

Variables

View Source
var UseColor = true

UseColor indicates if error messages should use colors.

Functions

func Err

func Err(e error) (err error)

Err returns an error which contains position information from the callee. The original position information is left unaltered if available.

func ErrNoPos

func ErrNoPos(e error) (err error)

ErrNoPos return an error which explicitly contains no position information.

func New

func New(text string) (err error)

New returns an error which contains position information from the callee.

Example
package main

import (
	"fmt"

	"github.com/mewkiz/pkg/errutil"
)

func main() {
	errutil.UseColor = false
	err := errutil.New("failure.")
	fmt.Println(err)

}
Output:

github.com/mewkiz/pkg/errutil_test.ExampleNew (err_test.go:11): failure.

func NewNoPos

func NewNoPos(text string) (err error)

NewNoPos returns an error which explicitly contains no position information. Further calls to Err will not embed any position information.

func NewNoPosf

func NewNoPosf(format string, a ...interface{}) (err error)

NewNoPosf returns a formatted error which explicitly contains no position information. Further calls to Err will not embed any position information.

func Newf

func Newf(format string, a ...interface{}) (err error)

Newf returns a formatted error which contains position information from the callee.

Types

type ErrInfo

type ErrInfo struct {
	// err is the original error message.
	Err error
	// contains filtered or unexported fields
}

ErrInfo is en error containing position information.

func (*ErrInfo) Error

func (e *ErrInfo) Error() string

Error returns an error string with position information.

The error format is as follows:

pkg.func (file:line): error: text

Jump to

Keyboard shortcuts

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