Skip to content

Commit f2e4339

Browse files
committed
fix errors package
1 parent 0284186 commit f2e4339

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

shared/errors/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var appErrors = map[ErrorCode]ErrorDetail{
3636
}
3737

3838
// AppError - App specific Error
39-
func AppError(errorCode ErrorCode, a ...interface{}) *errors.Error {
39+
func AppError(errorCode ErrorCode, a ...interface{}) error {
4040
return &errors.Error{
4141
Id: appErrors[errorCode].ID,
4242
Code: appErrors[errorCode].Code,
@@ -46,7 +46,7 @@ func AppError(errorCode ErrorCode, a ...interface{}) *errors.Error {
4646
}
4747

4848
// ValidationError - Unprocessable Entity
49-
func ValidationError(id, format string, a ...interface{}) *errors.Error {
49+
func ValidationError(id, format string, a ...interface{}) error {
5050
return &errors.Error{
5151
Id: id,
5252
Code: 422,

shared/errors/errors_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ package errors
33
// TODO: https://gochronicles.dev/posts/datastructures/list/singlylinkedlist/part-ii/
44

55
import (
6-
errs "errors"
6+
"errors"
77
"net/http"
88
"reflect"
99
"testing"
1010

11-
"github.com/micro/go-micro/errors"
11+
myErrors "github.com/micro/go-micro/errors"
1212
)
1313

1414
func TestErrors(t *testing.T) {
1515
testCases := []struct {
1616
name string
1717
values string
18-
want *errors.Error
18+
want error
1919
}{
2020
{"EC1", "not good", AppError(EC1)},
2121
}
2222

23-
testData := []*errors.Error{
24-
&errors.Error{
23+
testData := []*myErrors.Error{
24+
&myErrors.Error{
2525
Id: "go.micro.srv.account",
2626
Code: 422,
2727
Detail: "proto validation: sumo-val-error",
2828
Status: http.StatusText(422),
2929
},
3030
}
3131

32-
appErrTestData := []*errors.Error{
33-
&errors.Error{
32+
appErrTestData := []*myErrors.Error{
33+
&myErrors.Error{
3434
Id: "EC1",
3535
Code: 500,
3636
Detail: "not good",
@@ -55,13 +55,13 @@ func TestErrors(t *testing.T) {
5555
t.Fatalf("Expected %s got %s", e.Error(), ne.Error())
5656
}
5757

58-
ne2 := ValidationError("go.micro.srv.account", "proto validation: %v", errs.New("sumo-val-error"))
58+
ne2 := ValidationError("go.micro.srv.account", "proto validation: %v", errors.New("sumo-val-error"))
5959

6060
if e.Error() != ne2.Error() {
6161
t.Fatalf("Expected %s got %s", e.Error(), ne2.Error())
6262
}
6363

64-
pe := errors.Parse(ne.Error())
64+
pe := myErrors.Parse(ne.Error())
6565

6666
if pe == nil {
6767
t.Fatalf("Expected error got nil %v", pe)

0 commit comments

Comments
 (0)