Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tonic/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func Handler(h interface{}, status int, options ...func(*Route)) gin.HandlerFunc
input := reflect.New(in)
// Bind the body with the hook.
if err := bindHook(c, input.Interface()); err != nil {
handleError(c, BindError{message: err.Error(), typ: in})
handleError(c, BindError{message: err.Error(), typ: in, bindHookErr: err})
return
}
// Bind query-parameters.
Expand Down
6 changes: 6 additions & 0 deletions tonic/tonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func Tags(tags []string) func(*Route) {
// to bind parameters, to differentiate from errors returned
// by the handlers.
type BindError struct {
bindHookErr error
validationErr error
message string
typ reflect.Type
Expand Down Expand Up @@ -258,6 +259,11 @@ func (be BindError) ValidationErrors() validator.ValidationErrors {
return nil
}

// BindHookError returns the error from the bind process.
func (be BindError) BindHookError() error {
return be.bindHookErr
}

// An extractorFunc extracts data from a gin context according to
// parameters specified in a field tag.
type extractor func(*gin.Context, string) (string, []string, error)
Expand Down