Python Forum
an exception traceback and continue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
an exception traceback and continue
#4
Sound like a logging setup.
Example:
import my_log
 
def add(x, y):
   try:
       return(x + y)
   except Exception as error:
       my_log.logger.exception('msg')
 
if __name__ == '__main__':
   my_log.logger.info('Start')
   value = add(33, '50')
   my_log.logger.debug(value)
   my_log.logger.info('Finish')
   print(value)
One run without error and one with '50'
There are many cases where not give all error message to users make sense,
server,GUI...ect.
logg.log:
Output:
2018-01-17 08:35:50,623 - my_log - INFO - Start 2018-01-17 08:35:50,623 - my_log - DEBUG - 83 2018-01-17 08:35:50,623 - my_log - INFO - Finish 2018-01-17 08:36:18,791 - my_log - INFO - Start 2018-01-17 08:36:18,791 - my_log - ERROR - msg Traceback (most recent call last): File "_logging.py", line 5, in add return(x + y) TypeError: unsupported operand type(s) for +: 'int' and 'str' 2018-01-17 08:36:18,791 - my_log - DEBUG - None 2018-01-17 08:36:18,795 - my_log - INFO - Finish
setup my_log.py:
Reply


Messages In This Thread
an exception traceback and continue - by Skaperen - Jan-17-2018, 03:47 AM
RE: an exception traceback and continue - by snippsat - Jan-17-2018, 08:04 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Star python exception handling handling .... with traceback mg24 3 1,322 Nov-09-2022, 07:29 PM
Last Post: Gribouillis
  During handling of the above exception, another exception occurred Skaperen 7 26,989 Dec-21-2018, 10:58 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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