rkerror

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 3 Imported by: 21

Documentation

Overview

Package rkerror defines RK style API errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int           `json:"code" yaml:"code" example:"500"`
	Status  string        `json:"status" yaml:"status" example:"Internal Server Error"`
	Message string        `json:"message" yaml:"message" example:"Internal error occurs"`
	Details []interface{} `json:"details" yaml:"details"`
}

Error defines standard error types of rk style

func (*Error) Error

func (err *Error) Error() string

Error returns string of error

type ErrorResp

type ErrorResp struct {
	Err *Error `json:"error" yaml:"error"` // Err is RK style error type
}

ErrorResp is standard rk style error

func FromError

func FromError(err error) *ErrorResp

FromError converts error to ErrorResp

func New

func New(code int, msg string, details ...interface{}) *ErrorResp

New error response with options

func NewBadRequest

func NewBadRequest(msg string, details ...interface{}) *ErrorResp

func NewForbidden

func NewForbidden(msg string, details ...interface{}) *ErrorResp

func NewInternalError

func NewInternalError(msg string, details ...interface{}) *ErrorResp

func NewTimeout

func NewTimeout(msg string, details ...interface{}) *ErrorResp

func NewTooManyRequests

func NewTooManyRequests(msg string, details ...interface{}) *ErrorResp

func NewUnauthorized

func NewUnauthorized(msg string, details ...interface{}) *ErrorResp

Jump to

Keyboard shortcuts

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