Skip to content

Commit

Permalink
feat(bugsnug): pass error class to bugsnag explicitly (#19)
Browse files Browse the repository at this point in the history
* feat(bugsnug): improve grouping in bugsnug by passing error class explicitly

Signed-off-by: Michal Wasilewski <[email protected]>
  • Loading branch information
mwasilew2 authored Aug 23, 2024
1 parent a6f15b8 commit a8087d0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -333,6 +334,7 @@ func (ctx *Context) error(fields []interface{}, err error, internal InternalMess
if ctx.Notifier != nil && !strings.Contains(err.Error(), context.Canceled.Error()) {
var parentErr = err
var st stackTracer
var errorClass string
curSt, ok := parentErr.(stackTracer)
if ok {
st = curSt
Expand All @@ -353,13 +355,15 @@ func (ctx *Context) error(fields []interface{}, err error, internal InternalMess
}
if st != nil {
curErr = &errorWithStackFrames{err: st}
errorClass = reflect.TypeOf(st).String()
} else {
curErr = parentErr
errorClass = reflect.TypeOf(parentErr).String()
}

fieldsMap["original_error"] = parentErr.Error()

if err := ctx.Notifier.Notify(curErr, bugsnag.MetaData{FieldsTab: fieldsMap}, ctx); err != nil {
if err := ctx.Notifier.Notify(curErr, bugsnag.MetaData{FieldsTab: fieldsMap}, ctx, bugsnag.ErrorClass{Name: errorClass}); err != nil {
ctx.Errorf("error notifying the exception tracker: %v", err)
}
}
Expand Down

0 comments on commit a8087d0

Please sign in to comment.