enhancement: add error origin information to the errorcode package

This commit is contained in:
Florian Schade
2024-06-19 15:57:35 +02:00
parent 1f012ac9b5
commit 3280b22ffe
12 changed files with 180 additions and 153 deletions
+6 -1
View File
@@ -44,6 +44,11 @@ func TestFromCS3Status(t *testing.T) {
}
for _, test := range tests {
var e errorcode.Error
if errors.As(test.expected, &e) {
test.expected = e.WithOrigin(errorcode.ErrorOriginCS3)
}
if got := errorcode.FromCS3Status(test.status, test.err, test.ignore...); !reflect.DeepEqual(got, test.expected) {
t.Error("Test Failed: {} expected, received: {}", test.expected, got)
}
@@ -56,7 +61,7 @@ func TestFromStat(t *testing.T) {
err error
result error
}{
{nil, errors.New("some error"), errorcode.New(errorcode.GeneralException, "some error")},
{nil, errors.New("some error"), errorcode.New(errorcode.GeneralException, "some error").WithOrigin(errorcode.ErrorOriginCS3)},
{&provider.StatResponse{Status: &cs3rpc.Status{Code: cs3rpc.Code_CODE_OK}}, nil, nil},
}