forked from ebhomengo/niki
1
0
Fork 0

fix(niki): patch panic error caused by errors.As() function

This commit is contained in:
Iman Mirazimi 2024-01-05 15:51:10 +03:30
parent 3eea2c0d1d
commit ce762ac29c
17 changed files with 33 additions and 33 deletions

View File

@ -14,7 +14,7 @@ const (
)
func Error(err error) (message string, code int) {
var re *richerror.RichError
var re richerror.RichError
if !errors.As(err, &re) {
return err.Error(), http.StatusBadRequest
}

View File

@ -68,7 +68,7 @@ func (r RichError) Kind() Kind {
return r.kind
}
var re *RichError
var re RichError
if !errors.As(r.wrappedError, &re) {
return 0
}
@ -81,7 +81,7 @@ func (r RichError) Message() string {
return r.message
}
var re *RichError
var re RichError
if !errors.As(r.wrappedError, &re) {
return r.wrappedError.Error()
}

View File

@ -29,9 +29,9 @@ func (v Validator) ValidateAddRequest(req param.KindBoxAddRequest) (map[string]s
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -25,9 +25,9 @@ func (v Validator) ValidateDeleteRequest(req param.KindBoxDeleteRequest) (map[st
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -24,9 +24,9 @@ func (v Validator) ValidateGetRequest(req param.KindBoxGetRequest) (map[string]s
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -39,9 +39,9 @@ func (v Validator) ValidateUpdateRequest(req param.KindBoxUpdateRequest) (map[st
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -26,9 +26,9 @@ func (v Validator) ValidateAddRequest(req param.KindBoxReqAddRequest) (map[strin
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -25,9 +25,9 @@ func (v Validator) ValidateDeleteRequest(req param.KindBoxReqDeleteRequest) (map
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -24,9 +24,9 @@ func (v Validator) ValidateGetRequest(req param.KindBoxReqGetRequest) (map[strin
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -30,9 +30,9 @@ func (v Validator) ValidateUpdateRequest(req param.KindBoxReqUpdateRequest) (map
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -24,9 +24,9 @@ func (v Validator) ValidateGetRequest(req param.KindBoxGetRequest) (map[string]s
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -19,9 +19,9 @@ func (v Validator) ValidateUpdateRequest(req param.KindBoxGetAllRequest) (map[st
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -26,9 +26,9 @@ func (v Validator) ValidateAddRequest(req param.KindBoxReqAddRequest) (map[strin
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -25,9 +25,9 @@ func (v Validator) ValidateDeleteRequest(req param.KindBoxReqDeleteRequest) (map
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -24,9 +24,9 @@ func (v Validator) ValidateGetRequest(req param.KindBoxReqGetRequest) (map[strin
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -19,9 +19,9 @@ func (v Validator) ValidateGetAllRequest(req param.KindBoxReqGetAllRequest) (map
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}

View File

@ -31,9 +31,9 @@ func (v Validator) ValidateUpdateRequest(req param.KindBoxReqUpdateRequest) (map
); err != nil {
fieldErrors := make(map[string]string)
var errV *validation.Errors
var errV validation.Errors
if errors.As(err, &errV) {
for key, value := range *errV {
for key, value := range errV {
if value != nil {
fieldErrors[key] = value.Error()
}