errors

package
v0.0.0-...-20f3002 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// Prefix the error prefix, applies to each error's message.
	Prefix = ""
	// NewLine adds a new line to the end of each error's message
	// defaults to true
	NewLine = true
)

Functions

This section is empty.

Types

type Error

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

Error holds the error message, this message never really changes

Example
package main

import (
	"fmt"

	"github.com/kataras/iris/core/errors"
)

var errMessage = "User with mail: %s already exists"
var errUserAlreadyExists = errors.New(errMessage)
var userMail = "user1@mail.go"

func main() {
	fmt.Print(errUserAlreadyExists.Format(userMail))
	// first output first Output line
	fmt.Print(errUserAlreadyExists.Format(userMail).Append("Please change your mail addr"))
	// second output second and third Output lines

}
Output:

User with mail: user1@mail.go already exists
User with mail: user1@mail.go already exists
Please change your mail addr

func New

func New(errMsg string) *Error

New creates and returns an Error with a pre-defined user output message all methods below that doesn't accept a pointer receiver because actually they are not changing the original message

func (Error) Append

func (e Error) Append(format string, a ...interface{}) Error

Append adds a message to the predefined error message and returns a new error it does NOT change the original error's message

func (Error) AppendErr

func (e Error) AppendErr(err error) Error

AppendErr adds an error's message to the predefined error message and returns a new error it does NOT change the original error's message

func (Error) Error

func (e Error) Error() string

Error returns the message of the actual error implements the error

func (Error) Format

func (e Error) Format(a ...interface{}) Error

Format returns a formatted new error based on the arguments it does NOT change the original error's message

func (Error) IsAppended

func (e Error) IsAppended() bool

IsAppended returns true if the Error instance is created using original's Error.Append/AppendErr func

func (Error) Panic

func (e Error) Panic()

Panic output the message and after panics

func (Error) Panicf

func (e Error) Panicf(args ...interface{})

Panicf output the formatted message and after panics

func (Error) String

func (e Error) String() string

String returns the error message

func (Error) With

func (e Error) With(err error) error

With does the same thing as Format but it receives an error type which if it's nil it returns a nil error

Jump to

Keyboard shortcuts

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