Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
returning an error code
#1
my function that works on the file system should inform the caller what error it encounters and where. the where would just be the path in a str. i am pondering the best way to tell the caller what the error is. the obvious is to let the error raise an exception. but not all errors would normally do so such as discovering something not being the way that is wanted, such as a file having 600 bytes when wanting one with 512 bytes. the function and why it is called has a different kind of abstraction. i want the caller to be able to figure this out quickly. is it considered OK to return an int code number or a word in a str that can be tested by the caller?

i'm also thinking that i should just make up my own exceptions but i have never done that and don't know how involved that is.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
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