Skip to content

Commit b129962

Browse files
committed
Test joining wrapped errors
1 parent ab32df2 commit b129962

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

interfaces_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,36 @@ func TestSetException(t *testing.T) {
380380
},
381381
},
382382
},
383+
"Joined and wrapped errors": {
384+
exception: errors.Join(
385+
fmt.Errorf("wrapper: %w", errors.New("base error")),
386+
errors.New("joined"),
387+
),
388+
maxErrorCount: -1,
389+
expected: []Exception{
390+
{
391+
Value: "base error",
392+
Type: "*errors.errorString",
393+
Mechanism: &Mechanism{Type: "generic", ExceptionID: 0, IsExceptionGroup: true},
394+
},
395+
{
396+
Value: "wrapper: base error",
397+
Type: "*fmt.wrapError",
398+
Mechanism: &Mechanism{Type: "generic", ExceptionID: 1, ParentID: Pointer(0), IsExceptionGroup: true},
399+
},
400+
{
401+
Value: "joined",
402+
Type: "*errors.errorString",
403+
Mechanism: &Mechanism{Type: "generic", ExceptionID: 2, IsExceptionGroup: true},
404+
},
405+
{
406+
Value: "wrapper: base error\njoined",
407+
Type: "*errors.joinError",
408+
Stacktrace: &Stacktrace{Frames: []Frame{}},
409+
Mechanism: &Mechanism{Type: "generic", ExceptionID: 3, IsExceptionGroup: true},
410+
},
411+
},
412+
},
383413
}
384414

385415
for name, tc := range testCases {

0 commit comments

Comments
 (0)