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

CaptureRawPanic #114

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,32 @@ func CapturePanicAndWait(f func(), tags map[string]string, interfaces ...Interfa
return DefaultClient.CapturePanicAndWait(f, tags, interfaces...)
}

func CaptureRawPanic(panicErr interface{}, tags map[string]string, interfaces ...Interface) string {
return DefaultClient.CaptureRawPanic(panicErr, tags, interfaces...)
}

// Call in recover block
func (client *Client) CaptureRawPanic(panicErr interface{}, tags map[string]string, interfaces ...Interface) string {
var packet *Packet
switch rval := panicErr.(type) {
case nil:
return ""
case error:
packet = NewPacket(rval.Error(), append(append(interfaces, client.context.interfaces()...), NewException(rval, NewStacktrace(2, 3, client.includePaths)))...)
default:
rvalStr := fmt.Sprint(rval)
packet = NewPacket(rvalStr, append(append(interfaces, client.context.interfaces()...), NewException(errors.New(rvalStr), NewStacktrace(2, 3, client.includePaths)))...)
}
if tags == nil {
tags = map[string]string{"level":"panic"}
} else {
tags["level"] = "panic"
}

errorID, _ := client.Capture(packet, tags)
return errorID
}

func (client *Client) Close() {
close(client.queue)
}
Expand Down