Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 64c4af3

Browse files
committed
Use the innermost pkg/errors cause with a stacktrace
1 parent 263040c commit 64c4af3

File tree

4 files changed

+317
-241
lines changed

4 files changed

+317
-241
lines changed

client.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,23 +403,23 @@ type Client struct {
403403
// Initialize a default *Client instance
404404
var DefaultClient = newClient(nil)
405405

406-
func (c *Client) SetIgnoreErrors(errs []string) error {
406+
func (client *Client) SetIgnoreErrors(errs []string) error {
407407
joinedRegexp := strings.Join(errs, "|")
408408
r, err := regexp.Compile(joinedRegexp)
409409
if err != nil {
410410
return fmt.Errorf("failed to compile regexp %q for %q: %v", joinedRegexp, errs, err)
411411
}
412412

413-
c.mu.Lock()
414-
c.ignoreErrorsRegexp = r
415-
c.mu.Unlock()
413+
client.mu.Lock()
414+
client.ignoreErrorsRegexp = r
415+
client.mu.Unlock()
416416
return nil
417417
}
418418

419-
func (c *Client) shouldExcludeErr(errStr string) bool {
420-
c.mu.RLock()
421-
defer c.mu.RUnlock()
422-
return c.ignoreErrorsRegexp != nil && c.ignoreErrorsRegexp.MatchString(errStr)
419+
func (client *Client) shouldExcludeErr(errStr string) bool {
420+
client.mu.RLock()
421+
defer client.mu.RUnlock()
422+
return client.ignoreErrorsRegexp != nil && client.ignoreErrorsRegexp.MatchString(errStr)
423423
}
424424

425425
func SetIgnoreErrors(errs ...string) error {
@@ -666,7 +666,7 @@ func CaptureMessageAndWait(message string, tags map[string]string, interfaces ..
666666
return DefaultClient.CaptureMessageAndWait(message, tags, interfaces...)
667667
}
668668

669-
// CaptureErrors formats and delivers an error to the Sentry server.
669+
// CaptureError formats and delivers an error to the Sentry server.
670670
// Adds a stacktrace to the packet, excluding the call to this method.
671671
func (client *Client) CaptureError(err error, tags map[string]string, interfaces ...Interface) string {
672672
if client == nil {
@@ -683,13 +683,13 @@ func (client *Client) CaptureError(err error, tags map[string]string, interfaces
683683

684684
cause := pkgErrors.Cause(err)
685685

686-
packet := NewPacket(err.Error(), append(append(interfaces, client.context.interfaces()...), NewException(cause, GetOrNewStacktrace(cause, 1, 3, client.includePaths)))...)
686+
packet := NewPacket(err.Error(), append(append(interfaces, client.context.interfaces()...), NewException(cause, GetOrNewStacktrace(err, 1, 3, client.includePaths)))...)
687687
eventID, _ := client.Capture(packet, tags)
688688

689689
return eventID
690690
}
691691

692-
// CaptureErrors formats and delivers an error to the Sentry server using the default *Client.
692+
// CaptureError formats and delivers an error to the Sentry server using the default *Client.
693693
// Adds a stacktrace to the packet, excluding the call to this method.
694694
func CaptureError(err error, tags map[string]string, interfaces ...Interface) string {
695695
return DefaultClient.CaptureError(err, tags, interfaces...)
@@ -707,7 +707,7 @@ func (client *Client) CaptureErrorAndWait(err error, tags map[string]string, int
707707

708708
cause := pkgErrors.Cause(err)
709709

710-
packet := NewPacket(err.Error(), append(append(interfaces, client.context.interfaces()...), NewException(cause, GetOrNewStacktrace(cause, 1, 3, client.includePaths)))...)
710+
packet := NewPacket(err.Error(), append(append(interfaces, client.context.interfaces()...), NewException(cause, GetOrNewStacktrace(err, 1, 3, client.includePaths)))...)
711711
eventID, ch := client.Capture(packet, tags)
712712
if eventID != "" {
713713
<-ch

0 commit comments

Comments
 (0)