Files
grafana/pkg/api/frontendlogging/grafana_javascript_agent_sourcemaps.go
T
Mariell Hoversholm 750b094dda [release-10.4.18] Go: Bump to 1.24.2 (#103531)
* Go: Bump to 1.24.2

* CI: Update golangci-lint

* feat: update swagger

* fix: more lints

* fix: lints
2025-04-09 11:12:33 +02:00

30 lines
758 B
Go

package frontendlogging
import "context"
// TransformException will attempt to resolve all modified source locations in the stacktrace with original source locations
func TransformException(ctx context.Context, ex *Exception, store *SourceMapStore) *Exception {
if ex.Stacktrace == nil {
return ex
}
frames := []Frame{}
for _, frame := range ex.Stacktrace.Frames {
mappedFrame, err := store.resolveSourceLocation(ctx, frame)
if err != nil {
frames = append(frames, frame)
} else if mappedFrame != nil {
frames = append(frames, *mappedFrame)
} else {
frames = append(frames, frame)
}
}
return &Exception{
Type: ex.Type,
Value: ex.Value,
Stacktrace: &Stacktrace{Frames: frames},
Timestamp: ex.Timestamp,
}
}