Rename package "errs" to "errors"
Signed-off-by: Jingwen Peng <pengsrc@yunify.com>
This commit is contained in:
parent
03abd16068
commit
03e5a0572a
|
@ -14,7 +14,7 @@
|
||||||
// | limitations under the License.
|
// | limitations under the License.
|
||||||
// +-------------------------------------------------------------------------
|
// +-------------------------------------------------------------------------
|
||||||
|
|
||||||
package errs
|
package errors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
|
@ -14,9 +14,11 @@
|
||||||
// | limitations under the License.
|
// | limitations under the License.
|
||||||
// +-------------------------------------------------------------------------
|
// +-------------------------------------------------------------------------
|
||||||
|
|
||||||
package errs
|
package errors
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
// QingCloudError stores information of a QingCloud error response.
|
// QingCloudError stores information of a QingCloud error response.
|
||||||
type QingCloudError struct {
|
type QingCloudError struct {
|
|
@ -27,7 +27,7 @@ import (
|
||||||
|
|
||||||
"github.com/yunify/qingcloud-sdk-go/logger"
|
"github.com/yunify/qingcloud-sdk-go/logger"
|
||||||
"github.com/yunify/qingcloud-sdk-go/request/data"
|
"github.com/yunify/qingcloud-sdk-go/request/data"
|
||||||
"github.com/yunify/qingcloud-sdk-go/request/errs"
|
"github.com/yunify/qingcloud-sdk-go/request/errors"
|
||||||
"github.com/yunify/qingcloud-sdk-go/utils"
|
"github.com/yunify/qingcloud-sdk-go/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ func (u *Unpacker) parseError() error {
|
||||||
messageValue.IsValid() && messageValue.Type().String() == "string" &&
|
messageValue.IsValid() && messageValue.Type().String() == "string" &&
|
||||||
retCodeValue.Int() != 0 {
|
retCodeValue.Int() != 0 {
|
||||||
|
|
||||||
return &errs.QingCloudError{
|
return &errors.QingCloudError{
|
||||||
RetCode: int(retCodeValue.Int()),
|
RetCode: int(retCodeValue.Int()),
|
||||||
Message: messageValue.String(),
|
Message: messageValue.String(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/yunify/qingcloud-sdk-go/request/data"
|
"github.com/yunify/qingcloud-sdk-go/request/data"
|
||||||
"github.com/yunify/qingcloud-sdk-go/request/errs"
|
"github.com/yunify/qingcloud-sdk-go/request/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUnpackerUnpackHTTPRequest(t *testing.T) {
|
func TestUnpackerUnpackHTTPRequest(t *testing.T) {
|
||||||
|
@ -52,7 +52,7 @@ func TestUnpackerUnpackHTTPRequest(t *testing.T) {
|
||||||
|
|
||||||
type DescribeVolumesOutput struct {
|
type DescribeVolumesOutput struct {
|
||||||
StatusCode int `location:"statusCode"`
|
StatusCode int `location:"statusCode"`
|
||||||
Error *errs.QingCloudError
|
Error *errors.QingCloudError
|
||||||
|
|
||||||
Action string `json:"action" name:"action"`
|
Action string `json:"action" name:"action"`
|
||||||
RetCode int `json:"ret_code" name:"ret_code"`
|
RetCode int `json:"ret_code" name:"ret_code"`
|
||||||
|
@ -123,7 +123,7 @@ func TestUnpacker_UnpackHTTPRequestWithError(t *testing.T) {
|
||||||
err := unpacker.UnpackHTTPRequest(&data.Operation{}, httpResponse, &outputValue)
|
err := unpacker.UnpackHTTPRequest(&data.Operation{}, httpResponse, &outputValue)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
switch e := err.(type) {
|
switch e := err.(type) {
|
||||||
case errs.QingCloudError:
|
case errors.QingCloudError:
|
||||||
assert.Equal(t, e.RetCode, 1400)
|
assert.Equal(t, e.RetCode, 1400)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue