Alex
Tue, 31 Aug 2010 04:43:14 -0700
Hi all. I'm working on a thin wrapper around the unix crontab command (just the command, non the cron service). The module will do some simple operation like: - Read the crontab file - Adding a job to crontab identified by an id - Deleting a job - Deleting all jobs added
Now I have two questions:
1. Does it make sense to create a couple of custom exceptions like:
class CrontabDoesNotExist(Exception): pass
class CrontabSyntaxError(Exception): pass
Or I should use builtin exception?
2. Does it make sense to catch an exception raised by a function just to
raise your own custom exception? For instance
subprocess.check_call(['crontab','-l'])
will raise a CalledProcessError exception if the crontab of the current user
does not exist. Does it make sense to catch the exception just to raise my
own custom exception? For instance:
try:
subprocess.check_call(['crontab','-l'])
except CalledProcessError:
raise CrontabDoesNotExist()
Maybe I could also make the CrontabDoesNotExist exception more useful
printing a message to inform the user that the crontab does not exist for
the current user.
Thanks in advance.
Alex
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor