2022-06-28 02:25:30 -05:00
|
|
|
package frontendlogging
|
|
|
|
|
2023-08-10 03:32:12 -05:00
|
|
|
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 {
|
2022-06-28 02:25:30 -05:00
|
|
|
if ex.Stacktrace == nil {
|
|
|
|
return ex
|
|
|
|
}
|
|
|
|
frames := []Frame{}
|
|
|
|
|
|
|
|
for _, frame := range ex.Stacktrace.Frames {
|
|
|
|
frame := frame
|
2023-08-10 03:32:12 -05:00
|
|
|
mappedFrame, err := store.resolveSourceLocation(ctx, frame)
|
2022-06-28 02:25:30 -05:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|