Skip to content

Commit

Permalink
fix FactoryHandler.Call
Browse files Browse the repository at this point in the history
  • Loading branch information
junqiang.zhang committed Apr 3, 2022
1 parent a7ce4c9 commit fbd5b3d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gdi.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ func (p *HandlerFactory) Call(name string, args ...interface{}) (interface{}, er
}
}
values := m.mv.Call(vals)
if len(values) == 0 {
return nil, nil
}
if last := values[len(values)-1]; last.Type().Implements(reflect.TypeOf((*error)(nil)).Elem()) {
var er error
if last.Interface() != nil {
Expand All @@ -515,8 +518,12 @@ func (p *HandlerFactory) Call(name string, args ...interface{}) (interface{}, er
if len(values) >= 2 {
return values[0].Interface(), er
}
} else {
if len(values) == 1 {
return values[0].Interface(), nil
}
}
return nil, nil
return values[len(values)-1].Interface(), nil
} else {
return nil, fmt.Errorf("%s not found", name)
}
Expand Down

0 comments on commit fbd5b3d

Please sign in to comment.