Skip to content

Commit

Permalink
Reordered returnErr nil check
Browse files Browse the repository at this point in the history
as in majority of cases we expect err to be nil, this should provide better short-cutting
  • Loading branch information
ItsMeSamey authored Oct 18, 2024
1 parent 791f4ba commit dde670f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func (b *Bind) Must() *Bind {

// Check Should/Must errors and return it by usage.
func (b *Bind) returnErr(err error) error {
if !b.should && err != nil {
b.ctx.Status(StatusBadRequest)
return NewError(StatusBadRequest, "Bad request: "+err.Error())
if err == nil || b.should {
return err
}

return err
b.ctx.Status(StatusBadRequest)
return NewError(StatusBadRequest, "Bad request: "+err.Error())
}

// Struct validation.
Expand Down

0 comments on commit dde670f

Please sign in to comment.