Python Forum
python exception handling handling .... with traceback
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python exception handling handling .... with traceback
#2
Hi Team,

I found little bit of solution , which I was looking for.
I am splitting errors message into list. and printing each value.

is there any alternate easy solution. to get correct info. thanks in advance !
import traceback
try:
    print(4/0)
except ZeroDivisionError:
   error = traceback.format_exc()
   for e in (error.split('\n')):
       if not "Traceback" in e:
           print(e)
Thanks
mg
Reply


Messages In This Thread
RE: python exception handling handling .... with traceback - by mg24 - Nov-08-2022, 06:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trouble with Average Calculation Despite Error Handling autodecay 4 1,421 May-15-2025, 07:38 AM
Last Post: Pate
  Handling receiving updates from user in Telebot mohsenamiri 0 1,631 Aug-26-2024, 09:25 AM
Last Post: mohsenamiri
  Calculating Average with Error Handling mikasa 7 3,776 May-07-2024, 07:48 AM
Last Post: snippsat
  File Handling not working properly TheLummen 8 4,154 Feb-17-2024, 07:47 PM
Last Post: TheLummen
Question Why isn't getops handling all parameters? Calab 7 2,494 Feb-03-2023, 07:47 PM
Last Post: deanhystad
  painfully slow runtime when handling data dadazhu 3 2,188 Jan-20-2023, 07:11 PM
Last Post: snippsat
  file handling Newbee question middlecope 2 1,707 Jan-18-2023, 03:09 PM
Last Post: middlecope
  Python Traceback Error mg24 2 1,717 Nov-21-2022, 02:35 PM
Last Post: snippsat
Question log.exception() without arguments in old Python versions? cthart 5 2,425 Nov-19-2022, 07:09 PM
Last Post: Gribouillis
  Help needed with a "for loop" + error handling tamiri 2 8,303 May-27-2022, 12:21 PM
Last Post: tamiri

Forum Jump:

User Panel Messages

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