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

Capture extra info using interface{ExtraInfo() map[string]interface{}} #168

Closed
wants to merge 2 commits into from

Conversation

jsm
Copy link
Contributor

@jsm jsm commented Jan 31, 2018

Goal

Surface a way to be able to capture extra information

Related Issues

#134
#138
#146

How is this different?

  • Instead of changing the API, which would be a considerable change, use an interface on error and provide a function to wrap the error with extra information.
  • Allows setting extra information at the source, rather than having to manually do it wherever it's handled. It can be hard to pass the information needed up to the handler
  • Works even wrapped with github.com/pkg/errors

Public API Changes

raven.WrapWithExtra(err error, extraInfo map[string]interface{}) error
raven.NewPacketWithExtra(message string, extra Extra, interfaces ...Interface) *Packet

type Extra map[string]interface{}

type ErrWithExtra interface {
	Error() string
	Cause() error
	ExtraInfo() Extra
}

@mattrobenolt
Copy link
Contributor

This is clever. Could we get some tests? Otherwise, looks good. :)

@jsm jsm changed the title Capture extra info using interface{WithExtra() map[string]interface{}} Capture extra info using interface{ExtraInfo() map[string]interface{}} Jan 31, 2018
@jsm jsm force-pushed the with-extra branch 3 times, most recently from 7fb2270 to ebaf8f1 Compare February 1, 2018 01:41
JackWink added a commit to JackWink/raven-go that referenced this pull request May 9, 2018
Builds on getsentry#168 by adding test cases and removing unused interface
@JackWink JackWink mentioned this pull request May 9, 2018
JackWink added a commit to JackWink/raven-go that referenced this pull request May 17, 2018
Builds on getsentry#168 by adding test cases and removing unused interface
JackWink added a commit to JackWink/raven-go that referenced this pull request May 17, 2018
Builds on getsentry#168 by adding test cases and removing unused interface
mattrobenolt pushed a commit that referenced this pull request May 17, 2018
* Capture extra info using interface{ExtraInfo() map[string]interface{}}

Extract nested extras

* Fix tests for Go 1.10

A couple type errors in string formatting prevented the tests from
running. Runs 1.10.x on travis.

* Add new tests for error with extra

Builds on #168 by adding test cases and removing unused interface
@jheth
Copy link

jheth commented May 23, 2018

Can this be closed now that #190 landed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants