Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
returning an error code
#2
Nothing is simpler than writing your own exception
class MyException(RuntimeError):
    pass
class MySubException(MyException):
    pass

raise MySubException('That file is too large!')
The drawback of returning an error code is that it forces the caller to check the error code. On the other hand, if a function raises exceptions, you can just call the function and let the exceptions propagate.
Reply


Messages In This Thread
returning an error code - by Skaperen - Feb-08-2021, 06:55 PM
RE: returning an error code - by Gribouillis - Feb-09-2021, 07:11 AM
RE: returning an error code - by ndc85430 - Feb-28-2021, 02:54 PM
RE: returning an error code - by Skaperen - Mar-01-2021, 02:21 AM
RE: returning an error code - by Gribouillis - Mar-01-2021, 08:06 AM
RE: returning an error code - by Skaperen - Mar-02-2021, 12:30 AM
RE: returning an error code - by Gribouillis - Mar-02-2021, 09:33 AM
RE: returning an error code - by Skaperen - Mar-02-2021, 06:49 PM
RE: returning an error code - by ndc85430 - Mar-03-2021, 07:05 AM

Forum Jump:

User Panel Messages

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