error = sys.exc_info()[0].strip() <class 'AttributeError'>: type object 'RuntimeError' has no attribute 'strip' Furthermore reporting "value" instead of "type" gives more useful error messages