@@ -3,6 +3,8 @@ package sentry
3
3
import (
4
4
"errors"
5
5
"testing"
6
+
7
+ pkgErrors "github.com/pkg/errors"
6
8
)
7
9
8
10
func TestNewClientAllowsEmptyDSN (t * testing.T ) {
@@ -58,6 +60,7 @@ func TestCaptureMessageShouldSucceedWithoutNilScope(t *testing.T) {
58
60
func TestCaptureExceptionShouldSendEventWithProvidedError (t * testing.T ) {
59
61
client , scope , transport := setupClientTest ()
60
62
client .CaptureException (errors .New ("custom error" ), nil , scope )
63
+ assertEqual (t , transport .lastEvent .Exception [0 ].Type , "*errors.errorString" )
61
64
assertEqual (t , transport .lastEvent .Exception [0 ].Value , "custom error" )
62
65
}
63
66
@@ -67,6 +70,21 @@ func TestCaptureExceptionShouldNotFailWhenPassedNil(t *testing.T) {
67
70
assertEqual (t , transport .lastEvent .Message , "Called CaptureException with nil value" )
68
71
}
69
72
73
+ type customErr struct {}
74
+
75
+ func (e * customErr ) Error () string {
76
+ return "wat"
77
+ }
78
+
79
+ func TestCaptureExceptionShouldExtractCorrectTypeAndValueForWrappedErrors (t * testing.T ) {
80
+ client , scope , transport := setupClientTest ()
81
+ cause := & customErr {}
82
+ err := pkgErrors .WithStack (cause )
83
+ client .CaptureException (err , nil , scope )
84
+ assertEqual (t , transport .lastEvent .Exception [0 ].Type , "*sentry.customErr" )
85
+ assertEqual (t , transport .lastEvent .Exception [0 ].Value , "wat" )
86
+ }
87
+
70
88
func TestCaptureEventShouldSendEventWithProvidedError (t * testing.T ) {
71
89
client , scope , transport := setupClientTest ()
72
90
event := NewEvent ()
0 commit comments