Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exception_message.py 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """
  2. Check accessing Exception.message
  3. """
  4. # pylint: disable=import-error, no-absolute-import, broad-except
  5. from unknown import ExtensionException
  6. __revision__ = 0
  7. class SubException(IndexError):
  8. """ empty """
  9. _ = IndexError("test").message # [exception-message-attribute]
  10. _ = ZeroDivisionError("error").message # [exception-message-attribute]
  11. _ = ExtensionException("error").message
  12. _ = SubException("error").message # [exception-message-attribute]
  13. try:
  14. raise Exception('e')
  15. except Exception as exception:
  16. _ = exception.message # [exception-message-attribute]
  17. del exception.message # [exception-message-attribute]
  18. exception.message += 'hello world' # [exception-message-attribute]
  19. exception.message = 'hello world'
  20. class CompatException(Exception):
  21. """An exception which should work on py2 and py3."""
  22. def __init__(self, message=''):
  23. super(CompatException, self).__init__()
  24. self.message = message
  25. def __repr__(self):
  26. result = 'CompatException %s' % self.message
  27. return result.encode('utf-8')
  28. try:
  29. raise CompatException('message here')
  30. except CompatException as error:
  31. _ = error.message