server: add error helper

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-02-22 00:52:18 +03:00
parent 3247da3dd0
commit 09973af099
2 changed files with 78 additions and 0 deletions

19
server/errors_test.go Normal file
View File

@@ -0,0 +1,19 @@
package server
import (
"testing"
"github.com/unistack-org/micro/v3/errors"
)
func TestError(t *testing.T) {
e := NewError("svc1")
err := e.BadRequest("%s", "test")
merr, ok := err.(*errors.Error)
if !ok {
t.Fatal("error not *errors.Error")
}
if merr.Id != "svc1" {
t.Fatal("id != svc1")
}
}