errors

package
v0.0.0-...-8d8ec1c Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package errors - http 처리 상에 발생한 오류 관련 기능 제공 프키지

Package errors -

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRouteNotFound happens when no route was matched
	ErrRouteNotFound = NewWithCode(http.StatusNotFound, "no API found with those values")
	// ErrInvalidID represents an invalid identifier
	ErrInvalidID = NewWithCode(http.StatusBadRequest, "please provide a valid ID")
)

Functions

func Cause

func Cause(err error) error

Cause - 오류 발생 기반 정보 추출

func Errorf

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

Errorf - 지정한 포맷과 값을 기준으로 Stack Trace 정보 추가

func Handler

func Handler(rw http.ResponseWriter, req *http.Request, err interface{})

Handler - 오류 정보를 JSON 형식으로 변환

func New

func New(message string) error

New - 지정한 메시지를 기준으로 오류 정보 생성

func NotFound

func NotFound(rw http.ResponseWriter, req *http.Request)

NotFound - 조건에 맞는 Router 정보가 없는 경우 오류

func RecoveryHandler

func RecoveryHandler(rw http.ResponseWriter, req *http.Request, err interface{})

RecoveryHandler - Panic이 발생했을 때 처리를 위한 Recovery Handler 반환

func WithMessage

func WithMessage(err error, message string) error

WithMessage - 오류에 지정한 메시지 정보 추가

func WithStack

func WithStack(err error) error

WithStack - 오류검증을 위한 Stack Trace 정보 추가

func Wrap

func Wrap(err error, message string) error

Wrap - Stack Trace 정보들을 추가 설정한 오류 구성

func Wrapf

func Wrapf(err error, format string, args ...interface{}) error

Wrapf - Format 정보를 기준으로 Stack Trace 정보들을 추가 설정한 오류 구성

Types

type Error

type Error struct {
	Code    int    `json:"-"`
	Message string `json:"error"`
}

Error - error 인터페이스가 적용된 사용자 정의 오류 형식

func NewWithCode

func NewWithCode(code int, message string) *Error

NewWithCode - 지정한 상태 코드와 메시지를 기준으로 오류정보 생성

func (*Error) Error

func (e *Error) Error() string

Error - 오류 정보에서 메시지 반환

type Frame

type Frame uintptr

Frame represents a program counter inside a stack frame.

func (Frame) Format

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   path of source file relative to the compile time GOPATH
%+v   equivalent to %+s:%d

type StackTrace

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format

func (st StackTrace) Format(s fmt.State, verb rune)

Format -

Jump to

Keyboard shortcuts

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