errors

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0 Imports: 3 Imported by: 32

README

errors

Yum

Go Report Card License

What is this?

A simple errors package that dynamically prepends the package name.

How to install

Open a terminal and run the following:

$ go get --ldflags "-s -w" --trimpath -u github.com/mjwhitta/errors

Usage

Below is a sample usage:

package mypackage

import (
    "os"

    "github.com/mjwhitta/errors"
)

func OpenFileByName(name string) (*os.File, error) {
    var e error
    var f *os.File

    if name == "" {
        return nil, errors.New("no name was provided")
    }

    if f, e = os.Open(name); e != nil {
        return nil, errors.Newf("failed to open %s: %w", name, e)
    }

    return f, nil
}

Documentation

Index

Constants

View Source
const Version string = "1.0.3"

Version is the package version.

Variables

This section is empty.

Functions

func New

func New(str string) error

New will return a new error with a prefixed package name.

func Newf

func Newf(format string, a ...any) error

Newf will return a new error from format string with a prefixed package name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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