rkerror

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 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"`       // Code represent codes in response
	Status  string        `json:"status" yaml:"status"`   // Status represent string value of code
	Message string        `json:"message" yaml:"message"` // Message represent detail message
	Details []interface{} `json:"details" yaml:"details"` // Details is a list of details in any types in string
}

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