medaerror

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

View Source
const (
	STANDARD_ERROR = 1313
	NO_ERROR       = 8999 // PLEASE MAKE SURE THIS IS NOT USED ELSE WHERE!!!
)

Variables

View Source
var (
	New       func(int, string, string, interface{}) *MedaError = NewMedaErrPtr
	Errorf    func(string, ...any) MedaError                    = NewMedaErrStringFormat // error that only contains the error string with format, no code, no data
	NewString func(string) MedaError                            = NewMedaErrString       // error that only contains the error string, no code, no data
	Simple    func(string) MedaError                            = NewMedaErrString
)

Some function aliases to make it simpler and backward compatible

Functions

This section is empty.

Types

type MedaError

type MedaError struct {
	Code           int
	Message        string // usually for logging or console print
	ResponseString string // usually for API return message
	Data           interface{}
	FunctionName   string
	IsLogged       bool
	Err            error // original error, if this is nil, then MedaError is used for logging only
}

This is wrapper for go standard error

func NewMedaErr

func NewMedaErr(code int, message, respString string, data interface{}) MedaError

Constructor with complete variables

func NewMedaErrPtr

func NewMedaErrPtr(code int, message, respString string, data interface{}) *MedaError

Same with NewMedaErr but return pointer NOTE: do we need this?

func NewMedaErrPtrString

func NewMedaErrPtrString(message string) *MedaError

Same with NewMedaErr but return pointer NOTE: do we need this?

func NewMedaErrString

func NewMedaErrString(message string) MedaError

Constructor with only message, rest are default value

func NewMedaErrStringFormat

func NewMedaErrStringFormat(format string, a ...any) MedaError

Constructor with Printf format

func (MedaError) Error

func (m MedaError) Error() string

To implement standard golang Error type

func (MedaError) Log

func (m MedaError) Log() string

Yes this is the same as Error() but for readibility sometimes use Log() for logging is clearer

func (MedaError) Pretty

func (m MedaError) Pretty() string

Print both message and response in pretty way with newlines, possibly for debugging

func (MedaError) Response

func (m MedaError) Response() string

Return the response string usually that needed for API handler

func (MedaError) String

func (m MedaError) String() string

Print both the mssage and response

Jump to

Keyboard shortcuts

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