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

Commit

Permalink
capture raw recover error
Browse files Browse the repository at this point in the history
  • Loading branch information
kusora committed Nov 10, 2016
1 parent b8684db commit 3d95c15
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit 3d95c15

Please sign in to comment.