err

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2018 License: MIT Imports: 1 Imported by: 0

README

Err - string errors

Read Dave Cheney article about constant errors.

As constants of the Error type are not variables, they are immutable.

Usage:

import(
    ."github.com/ninedraft/boxofstuff/err"
)

const (
    ErrInvalidConfigFile Err = "invalid config file"
    ErrInvalidFilePath Err = "invalid file path"
    ErrIvalidEMail Err = "invalid e-mail"
)

func loadConfig(filePath string) error {
    // ...
    if invalidConfig(configText) {
        return ErrInvalidConfigFile
    }
}

func main() {
    switch loadConfig("./config.toml") {
    case nil:
        // yay
    case ErrInvalidConnfig:
        // do stuff
    case ErrInvalidFilePath:
        // do stuff
    default:
        // do stuff
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err string

Err - string err Usage:

``` import(

. "github.com/ninedraft/boxofstuff"

)

const(

ErrInvalidConfigFile Err = "invalid config file"

) ```

func Errorf

func Errorf(format string, args ...interface{}) Err

Errorf - creates Err from formatted string

func (Err) Error

func (err Err) Error() string

func (Err) String

func (err Err) String() string

Jump to

Keyboard shortcuts

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