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

Commit

Permalink
Merge pull request #1 from kusora/refine
Browse files Browse the repository at this point in the history
modify capture panic
  • Loading branch information
kusora committed Feb 29, 2016
2 parents 1cc47a9 + 0230c10 commit 105282e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,35 @@ func CapturePanic(f func(), tags map[string]string, interfaces ...Interface) (in
return DefaultClient.CapturePanic(f, tags, interfaces...)
}

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

func (client *Client) CaptureRawPanic(panicErr interface{}, tags map[string]string, interfaces ...Interface) string {
// Note: This doesn't need to check for client, because we still want to go through the defer/recover path
// Down the line, Capture will be noop'd, so while this does a _tiny_ bit of overhead constructing the
// *Packet just to be thrown away, this should not be the normal case. Could be refactored to
// be completely noop though if we cared.
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 105282e

Please sign in to comment.