How to attach custom data to python exception?

k.art

Posted on
Aug 29 2016

At the moment errors like InvalidUrl("http://raygun.io") and InvalidUrl("http://raygun.com") show up as two different errors in the UI.

Can I do something like:

e = InvalidUrl()
e.customData = <dictionary or string or whatever>
raise e

to group the two errors together but still have some custom information available?


Callum

Posted on
Aug 29 2016

Yup, you sure can! This is available as the manual send_exception API:

client.send_exception(exception=e, userCustomData={})

where e is the exception object. 'userCustomData' is of type Dict and can contain whatever data you like including the string of the invalid URL. Full documentation for this is available at https://github.com/MindscapeHQ/raygun4py#sending-functions, and I'm just clarifying this on the official raygun.com docs for you.


k.art

Posted on
Aug 29 2016

Awesome, that should do! Thanks!


Reply