Solved

Automatically forward errors via email

Posted on 2011-09-12
5
373 Views
Last Modified: 2012-05-12
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
Comment
Question by:dolamitejenkins
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:mish33
ID: 36527646
Use try/except :
def myfunc():
  # to do something useful

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

Open in new window

0
 

Author Comment

by:dolamitejenkins
ID: 36529447
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
 
LVL 15

Accepted Solution

by:
mish33 earned 500 total points
ID: 36530010
Wrap your main function - it will catch all exceptions (in the main thread) in all modules.
0
 

Author Comment

by:dolamitejenkins
ID: 36531344
Thanks
0
 

Author Closing Comment

by:dolamitejenkins
ID: 36531835
thank you
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now