rename err.BindArgument() to err.Put()

This commit is contained in:
Adrien Marquès 2018-10-01 21:21:27 +02:00
parent ee19846ddc
commit 85a0521723
2 changed files with 9 additions and 9 deletions

View File

@ -14,9 +14,9 @@ type Error struct {
Arguments []interface{}
}
// BindArgument adds an argument to the error
// Put adds an argument to the error
// to be displayed back to API caller
func (e *Error) BindArgument(arg interface{}) {
func (e *Error) Put(arg interface{}) {
/* (1) Make slice if not */
if e.Arguments == nil {

View File

@ -135,7 +135,7 @@ func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) {
httpMethod := strings.ToUpper(req.Method)
if err != nil {
httpErr := e.UncallableController
httpErr.BindArgument(err)
httpErr.Put(err)
httpError(res, httpErr)
log.Printf("err( %s )\n", err)
return
@ -204,7 +204,7 @@ func (s *Server) extractParameters(req *apirequest.Request, methodParam map[stri
/* (2) Required & missing */
if !isset && !param.Optional {
err = e.MissingParam
err.BindArgument(name)
err.Put(name)
return nil, err
}
@ -233,8 +233,8 @@ func (s *Server) extractParameters(req *apirequest.Request, methodParam map[stri
waitFile, gotFile := param.Type == "FILE", p.File
if gotFile && !waitFile || !gotFile && waitFile {
err = e.InvalidParam
err.BindArgument(param.Rename)
err.BindArgument("FILE")
err.Put(param.Rename)
err.Put("FILE")
return nil, err
}
@ -248,9 +248,9 @@ func (s *Server) extractParameters(req *apirequest.Request, methodParam map[stri
if s.checker.Run(param.Type, p.Value) != nil {
err = e.InvalidParam
err.BindArgument(param.Rename)
err.BindArgument(param.Type)
err.BindArgument(p.Value)
err.Put(param.Rename)
err.Put(param.Type)
err.Put(p.Value)
break
}