Documentation ¶
Index ¶
- Constants
- Variables
- func AppendDebugMsg(err error, debugMsg ...string) error
- func BadReqError(err error, debugMsg ...string) error
- func BuildResponse(data interface{}, err error) (int, interface{})
- func GetErrorCode(err error) (code int)
- func GetErrorHTTPCode(err error) (httpCode int, status bool)
- func GetPriorityValue(a ...interface{}) (pVal interface{})
- func StackTrace(depth int) (funcName string, file string, line int)
- func Unmarshal(reqBody string, structModel interface{}) (err error)
- func UnmarshalError(err error, debugMsg ...string) error
- func VError(debugMsg ...string) error
- type Error
- type MsgResp
- type Resp
Constants ¶
const ( VALIDATE_ERROR = 101 //Primary Validation fail NO_ERROR = 0 )
Error Code. PLEASE Map New Error Code To The HTTP Code Map Below.
const ( STATUS_OK = 200 STATUS_BAD_REQUEST = 400 )
HTTP Code
const INVALID_REQUEST_MSG = "Invalid Request, Please provide correct input"
Error Messages
const PACKAGE_NAME = "github.com/mayur-tolexo/drift/lib"
Variables ¶
var ( //ErrorHTTPCode : Error Code to Http Code map ErrorHTTPCode = map[int]int{ NO_ERROR: STATUS_OK, VALIDATE_ERROR: STATUS_BAD_REQUEST, } )
Functions ¶
func AppendDebugMsg ¶
AppendDebugMsg : append debugMsg in error
func BadReqError ¶
BadReqError : error occured while validating request like while typecasting request, fk in request dosn't exists
func BuildResponse ¶
BuildResponse : creates the response of API
func GetErrorCode ¶
GetErrorCode : Get Error Code from *Error
func GetErrorHTTPCode ¶
GetErrorHTTPCode : Get HTTP code from error code. Please check for httpCode = 0.
func GetPriorityValue ¶
func GetPriorityValue(a ...interface{}) (pVal interface{})
GetPriorityValue : get the value by priority
func StackTrace ¶
StackTrace : Get function name, file name and line no of the caller function Depth is the value from which it will start searching in the stack
func UnmarshalError ¶
UnmarshalError : error occured while unmarshal
Types ¶
type Error ¶
type Error struct { Code int `json:"code"` Msg string `json:"Message"` Trace string `json:"trace,omitempty"` DebugMsg string `json:"debug_msg,omitempty"` }
Error Model
type MsgResp ¶
type MsgResp struct { Data interface{} Msg string }
MsgResp : Message response for create/update/delete api