mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
Merge pull request #5581 from yousong/bugfix/yousong-httperrors
httperrors: fix passing "params" argument
This commit is contained in:
@@ -197,9 +197,9 @@ func NewClientError(msg string, params ...interface{}) *httputils.JSONClientErro
|
||||
}
|
||||
|
||||
func NewUnclassifiedError(msg string, params ...interface{}) *httputils.JSONClientError {
|
||||
return httputils.NewJsonClientError(httpErrorCode[errors.ErrUnclassified], string(errors.ErrUnclassified), msg, params)
|
||||
return httputils.NewJsonClientError(httpErrorCode[errors.ErrUnclassified], string(errors.ErrUnclassified), msg, params...)
|
||||
}
|
||||
|
||||
func NewTooLargeEntityError(msg string, params ...interface{}) *httputils.JSONClientError {
|
||||
return httputils.NewJsonClientError(httpErrorCode[ErrTooLarge], string(ErrTooLarge), msg, params)
|
||||
return httputils.NewJsonClientError(httpErrorCode[ErrTooLarge], string(ErrTooLarge), msg, params...)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package httperrors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGeneralError(t *testing.T) {
|
||||
t.Run("unclassified", func(t *testing.T) {
|
||||
t.Run("no fmt", func(t *testing.T) {
|
||||
err := fmt.Errorf("i am an unclassified error")
|
||||
jce := NewGeneralError(err)
|
||||
if strings.Contains(jce.Details, "%!(EXTRA") {
|
||||
t.Errorf("bad error formating: %v", jce)
|
||||
}
|
||||
})
|
||||
t.Run("fmt", func(t *testing.T) {
|
||||
err := fmt.Errorf("i am error with plain %%s")
|
||||
jce := NewGeneralError(err)
|
||||
if strings.Contains(jce.Details, "%!(EXTRA") {
|
||||
t.Errorf("bad error formating: %v", jce)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func NewSSHtoolSolCommand(ctx context.Context, userCred mcclient.TokenCredential
|
||||
}
|
||||
conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", ip, port), time.Second*2)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("IPAddress %s:%d not accessable", ip, port)
|
||||
return nil, fmt.Errorf("IPAddress %s:%d not accessible", ip, port)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user