Documentation
¶
Index ¶
- Constants
- Variables
- type MedaError
- func NewMedaErr(code int, message, respString string, data interface{}) MedaError
- func NewMedaErrPtr(code int, message, respString string, data interface{}) *MedaError
- func NewMedaErrPtrString(message string) *MedaError
- func NewMedaErrString(message string) MedaError
- func NewMedaErrStringFormat(format string, a ...any) MedaError
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 ¶
Constructor with complete variables
func NewMedaErrPtr ¶
Same with NewMedaErr but return pointer NOTE: do we need this?
func NewMedaErrPtrString ¶
Same with NewMedaErr but return pointer NOTE: do we need this?
func NewMedaErrString ¶
Constructor with only message, rest are default value
func NewMedaErrStringFormat ¶
Constructor with Printf format
func (MedaError) Log ¶
Yes this is the same as Error() but for readibility sometimes use Log() for logging is clearer
func (MedaError) Pretty ¶
Print both message and response in pretty way with newlines, possibly for debugging
Click to show internal directories.
Click to hide internal directories.