Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

Automatically forward errors via email

I want to run code inside my program that will record and send any error that occurs whether handled or not to me via email or some other method , but especially not handled... can you point me in a direction of and example
0
dolamitejenkins
Asked:
dolamitejenkins
  • 3
  • 2
1 Solution
 
mish33Commented:
Use try/except :
def myfunc():
  # to do something useful

try :
  myfunc()
except :
  # mail error
  sendmail(sys.exc_info())

Open in new window

0
 
dolamitejenkinsAuthor Commented:
my program is about 2000 lines ... when people start using it How can I collect all the error that occur ... this seems to capture for one module... any thoughts ?
0
 
mish33Commented:
Wrap your main function - it will catch all exceptions (in the main thread) in all modules.
0
 
dolamitejenkinsAuthor Commented:
Thanks
0
 
dolamitejenkinsAuthor Commented:
thank you
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now