response

package
v0.9.26 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NO_DATA_FOUND     = "NO-DATA-FOUND"
	SYSTEM_FAULT      = "SYSTEM_FAULT"
	SYSTEM_FAULT_DESC = "خطای سیستمی"
)

Variables

This section is empty.

Functions

func GetDescFromCode added in v0.3.21

func GetDescFromCode(code string, data any, errDescList map[string]string) (string, any)

func JustPrintResp

func JustPrintResp(respBytes []byte, desc string, status int) (int, map[string]string, any, error)

func ParseRemoteRespJson

func ParseRemoteRespJson(respBytes []byte, desc string, status int) (int, map[string]string, any, error)

func ParseWsRemoteResp

func ParseWsRemoteResp(respBytes []byte, desc string, status int) (int, map[string]string, any, error)

Types

type DbResponse

type DbResponse struct {
	Status      int    `json:"status"`
	Description string `json:"description"`
	Result      any    `json:"result"`
	ErrorCode   string `json:"error_code,omitempty"`
}

type ErrorData added in v0.9.5

type ErrorData struct {
	Status      int
	Description string
	Message     any
	// contains filtered or unexported fields
}

func (ErrorData) Child added in v0.9.5

func (e ErrorData) Child(err ErrorState) ErrorState

func (ErrorData) ChildErr added in v0.9.5

func (e ErrorData) ChildErr(err error) ErrorState

func (ErrorData) Error added in v0.9.5

func (e ErrorData) Error() string

func (ErrorData) Format added in v0.9.13

func (e ErrorData) Format(header string, stack *strings.Builder)

func (ErrorData) GetDescription added in v0.9.5

func (e ErrorData) GetDescription() string

func (ErrorData) GetInput added in v0.9.6

func (e ErrorData) GetInput() any

func (ErrorData) GetMessage added in v0.9.5

func (e ErrorData) GetMessage() any

func (ErrorData) GetStatus added in v0.9.5

func (e ErrorData) GetStatus() int

func (*ErrorData) Input added in v0.9.5

func (e *ErrorData) Input(in any) ErrorState

func (ErrorData) SetDescription added in v0.9.5

func (e ErrorData) SetDescription(desc string) ErrorState

func (ErrorData) SetMessage added in v0.9.5

func (e ErrorData) SetMessage(msg any) ErrorState

func (ErrorData) SetStatus added in v0.9.5

func (e ErrorData) SetStatus(status int) ErrorState

func (ErrorData) WsResponse added in v0.9.5

func (e ErrorData) WsResponse() string

type ErrorResponse

type ErrorResponse struct {
	Code        string `json:"code"`
	Description any    `json:"description"`
}

func FormatErrorResp

func FormatErrorResp(errs error, trans ut.Translator) []ErrorResponse

func GetErrorsArray

func GetErrorsArray(message string, data any) []ErrorResponse

func GetErrorsArrayWithMap

func GetErrorsArrayWithMap(incomingDesc string, data any, errDescList map[string]string) []ErrorResponse

type ErrorState

type ErrorState interface {
	Error() string
	Input(in any) ErrorState
	GetInput() any
	WsResponse() string
	SetStatus(int) ErrorState
	SetDescription(string) ErrorState
	SetMessage(any) ErrorState
	ChildErr(error) ErrorState
	Child(ErrorState) ErrorState
	GetStatus() int
	GetDescription() string
	GetMessage() any
}

func Error

func Error(status int, desc string, message any, err error) ErrorState

func Errors added in v0.9.12

func Errors(status int, desc string, message any, err ErrorState) ErrorState

func ToError

func ToError(desc string, message any, err error) ErrorState

func ToErrorState

func ToErrorState(err error) ErrorState

type InternalError

type InternalError struct {
	Desc    string
	Message any
}

func (InternalError) Error

func (e InternalError) Error() string

type Receipt

type Receipt struct {
	Id    string `json:"id"`
	Title string `json:"title"`
	Rows  []any  `json:"rows"`
}

type ResponseHandler

type ResponseHandler interface {
	GetErrorsArray(message string, data any) []ErrorResponse
	HandleErrorState(err error, status int, message string, data any, w webFramework.WebFramework)
	Respond(code, status int, message string, data any, abort bool, w webFramework.WebFramework)
	RespondWithReceipt(code, status int, message string, data any, printData *Receipt, abort bool, w webFramework.WebFramework)
	OK(w webFramework.WebFramework, resp any)
	OKWithReceipt(w webFramework.WebFramework, resp any, receipt *Receipt)
	Error(w webFramework.WebFramework, err ErrorState)
}

type WsRemoteResponse

type WsRemoteResponse struct {
	Status      int             `json:"status"`
	Description string          `json:"description"`
	Result      any             `json:"result,omitempty"`
	ErrorData   []ErrorResponse `json:"errors,omitempty"`
}

func (WsRemoteResponse) ToErrorState added in v0.1.7

func (e WsRemoteResponse) ToErrorState() ErrorState

type WsResponse

type WsResponse struct {
	Status       int      `json:"status"`
	Description  string   `json:"description"`
	Result       any      `json:"result,omitempty"`
	ErrorData    any      `json:"errors,omitempty"`
	PrintReceipt *Receipt `json:"printReceipt,omitempty"`
}

Jump to

Keyboard shortcuts

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