package models

type resCode int

const codeBase = 1000

const (
	CodeSuccess resCode = iota + codeBase
)

var codeMsg = map[resCode]string{
	CodeSuccess:"success",
}

func (r resCode) String() string {
	if res,ok:=codeMsg[r];ok{
		return res
	}

	return codeMsg[CodeSuccess]
}

type BaseError struct {
	Code resCode
	Msg  string
}

func (b *BaseError) Error() string {
	if b.Msg != "" {
		return b.Msg
	}

	return b.Code.String()
}
