Documentation ¶
Index ¶
Constants ¶
View Source
const ( ErrSvcCodeDuplicatedKey = "duplicated_key" ErrSvcCodeForeignKeyViolated = "foreign_key_violation" ErrSvcCodeRecordNotFound = "record_not_found" ErrSvcCodeUnregistered = "unregistered" ErrSvcCodeNone = "success" )
Variables ¶
View Source
var ( ErrAuthentication = errors.New("authentication_error") ErrBadJson = errors.New("bad_json") ErrBadHierarchy = errors.New("bad_hierarchy") ErrAlreadyMax = errors.New("already_max") ErrIdNotInteger = errors.New("id_not_integer") ErrBadQueryParam = errors.New("bad_query_param") ErrHttpClient = errors.New("http_client_error") ErrBadInput = errors.New("bad_input") )
View Source
var ErrorMap = map[error]CodePair{ gorm.ErrDuplicatedKey: NewCodePair(http.StatusBadRequest, ErrSvcCodeDuplicatedKey), gorm.ErrForeignKeyViolated: NewCodePair(http.StatusBadRequest, ErrSvcCodeForeignKeyViolated), gorm.ErrRecordNotFound: NewCodePair(http.StatusNotFound, ErrSvcCodeRecordNotFound), sql.ErrNoRows: NewCodePair(http.StatusNotFound, ErrSvcCodeRecordNotFound), ErrAuthentication: NewCodePair(http.StatusUnauthorized, ErrAuthentication.Error()), ErrBadJson: NewCodePair(http.StatusBadRequest, ErrBadJson.Error()), ErrBadHierarchy: NewCodePair(http.StatusBadRequest, ErrBadHierarchy.Error()), ErrAlreadyMax: NewCodePair(http.StatusForbidden, ErrAlreadyMax.Error()), ErrIdNotInteger: NewCodePair(http.StatusBadRequest, ErrIdNotInteger.Error()), ErrBadQueryParam: NewCodePair(http.StatusBadRequest, ErrBadQueryParam.Error()), ErrHttpClient: NewCodePair(http.StatusInternalServerError, ErrHttpClient.Error()), }
Functions ¶
This section is empty.
Types ¶
type CodePair ¶
func NewCodePair ¶
type Service ¶
type Service struct { }
func NewService ¶
func (*Service) Map ¶
func (s *Service) Map(err error) StatusInfo
type StatusInfo ¶
func NewStatusInfo ¶
func NewStatusInfo(httpStatusCode int, serviceErrorCode string, serviceErrorMessage string) StatusInfo
Click to show internal directories.
Click to hide internal directories.