Python Forum
raise exception instead of return None
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raise exception instead of return None
#5
Insufficient file space would be an IOError. Not enough calculation information sounds like a ValueError. If you know why the error is occurring, it's better to give that information with a more specific error type. If you don't know, you could give the catch all RuntimeError, or you could make your own exception:

class DidntWorkOutError(RuntimeError):
    pass
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: raise exception instead of return None - by ichabod801 - Jul-19-2018, 01:27 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  SystemError: error return without exception set!!! faryad13 3 3,738 Oct-23-2020, 02:32 PM
Last Post: ATARI_LIVE
  raise exception within generator bermudj 3 3,005 Jun-06-2020, 11:56 AM
Last Post: buran
  can i raise an exception in a try clause? Skaperen 14 5,801 Dec-19-2019, 12:29 AM
Last Post: Skaperen
  Changing a traceback message without a 2nd raise Clunk_Head 1 2,007 Jul-14-2019, 12:45 AM
Last Post: Gribouillis
  During handling of the above exception, another exception occurred Skaperen 7 26,951 Dec-21-2018, 10:58 AM
Last Post: Gribouillis
  "Raise SMTPException("SMTP AUTH extension not supported by server.") NajeebUllah 3 8,013 Mar-16-2018, 09:45 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020