1

What is the difference in getting exception message via str(e) and e.message in

except Exception as e:
    ...

block of code

user2052436
  • 4,321
  • 1
  • 25
  • 46

1 Answers1

4

If e doesn't have a message attribute, e.message will raise an AttributeError. str(e), on the other hand, won't do anything worse than return an empty string.

chepner
  • 497,756
  • 71
  • 530
  • 681