errors

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: BSD-3-Clause Imports: 1 Imported by: 4

Documentation

Overview

Package errors provide an error type with code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type E

type E struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Name    string `json:"name,omitempty"`
	// contains filtered or unexported fields
}

E define custom error that wrap underlying error with custom code, message, and name.

The Code field is required, used to communicate the HTTP response code. The Message field is optional, it's used to communicate the actual error message from server, to be readable by human. The Name field is optional, intended to be consumed by program, for example, to provide a key as translation of Message into user's locale defined language.

func Internal

func Internal(err error) *E

Internal define an error caused by server.

func InvalidInput

func InvalidInput(field string) *E

InvalidInput generate an error for invalid input.

func (*E) Error

func (e *E) Error() string

Error implement the error interface.

func (*E) Unwrap added in v0.11.0

func (e *E) Unwrap() error

Unwrap return the internal error.

Jump to

Keyboard shortcuts

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