Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when running the example script from the Heroku docs #45

Closed
hheimbuerger opened this issue Jun 4, 2016 · 2 comments
Closed

Comments

@hheimbuerger
Copy link

hheimbuerger commented Jun 4, 2016

Using raygun4py 3.1.2 and Python 2.7.10, I was following the official getting started instructions from Heroku: https://devcenter.heroku.com/articles/raygun#using-with-python

Here's my entire test script (running locally, not on Heroku, with RAYGUN_APIKEY set):

import os, sys, logging
from raygun4py import raygunprovider

logger = logging.getLogger("mylogger")

rgHandler = raygunprovider.RaygunHandler(os.environ.get('RAYGUN_APIKEY'))

logger.addHandler(rgHandler)

def log_exception(exc_type, exc_value, exc_traceback):
    print "Logging: %s" % exc_value
    logger.error("A python error occurred", exc_info = (exc_type, exc_value, exc_traceback))

sys.excepthook = log_exception

(a, b) = (1, 2, 3,)

And here's the error I'm getting from raygun4py:

Error in sys.excepthook:
Logging: too many values to unpack
Traceback (most recent call last):
  File "test.py", line 11, in log_exception
    logger.error("A python error occurred", exc_info = (exc_type, exc_value, exc_traceback))
  File "C:\Python\2.7\lib\logging\__init__.py", line 1191, in error
    self._log(ERROR, msg, args, **kwargs)
  File "C:\Python\2.7\lib\logging\__init__.py", line 1284, in _log
    self.handle(record)
  File "C:\Python\2.7\lib\logging\__init__.py", line 1294, in handle
    self.callHandlers(record)
  File "C:\Python\2.7\lib\logging\__init__.py", line 1334, in callHandlers
    hdlr.handle(record)
  File "C:\Python\2.7\lib\logging\__init__.py", line 757, in handle
    self.emit(record)
  File "C:\Python\2.7\lib\site-packages\raygun4py\raygunprovider.py", line 183, in emit
    self.sender.send_exception(userCustomData=userCustomData)
  File "C:\Python\2.7\lib\site-packages\raygun4py\raygunprovider.py", line 97, in send_exception
    errorMessage = raygunmsgs.RaygunErrorMessage(exc_type, exc_value, exc_traceback, options)
  File "C:\Python\2.7\lib\site-packages\raygun4py\raygunmsgs.py", line 118, in __init__
    self.className = exc_type.__name__
AttributeError: 'NoneType' object has no attribute '__name__'

Original exception was:
Traceback (most recent call last):
  File "test.py", line 15, in <module>
    (a, b) = (1, 2, 3,)
ValueError: too many values to unpack

Obviously, the second exception is correct and to be expected, but the first one is not.

@hheimbuerger
Copy link
Author

hheimbuerger commented Jun 4, 2016

I've since figured out that the code from the official documentation works, but it's still a pretty bad experience that the example did not work. (And not exactly fitting the "Real time error reporting you can set up in under 5 minutes!" claim.)

Here's the working version:

import os, sys
from raygun4py import raygunprovider

rgHandler = raygunprovider.RaygunSender(os.environ.get('RAYGUN_APIKEY'))

def handle_exception(exc_type, exc_value, exc_traceback):
    rgHandler.send_exception(exc_info=(exc_type, exc_value, exc_traceback))
    sys.__excepthook__(exc_type, exc_value, exc_traceback)

sys.excepthook = handle_exception

(a, b) = (1, 2, 3,)

@fundead
Copy link
Contributor

fundead commented Jun 6, 2016

Thanks for alerting us to this - the documentation on Heroku was outdated and for the original API, your corrected example is idiomatic for the current release. I'll get it tidied up for you shortly.

Regards,

Callum Gavin
Raygun Limited

@fundead fundead closed this as completed Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants