code: def get_exception_message(instance):
      '''Try to get the exception message or the class name.'''
      args = getattr(instance, 'args', None)
  
      if args:
          return str(instance)
  
      try:
          return type(instance).__name__
      except AttributeError:
          return str(instancef get_exception_message(instance):
      '''Try to get the exception message or the class name.'''
      args = getattr(instance, 'args', None)
  
      if args:
          return str(instance)
  
      try:
          return type(instance).__name__
      except AttributeError:
          return str(instance)
docs: Try to get the exception message or the class name.