Python Forum
Problems with not having exceptions crash my script
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problems with not having exceptions crash my script
#2
There's a reason why exceptions are thrown.
You should capture and analyze all of them, as it's something you're doing wrong that's creating them.

Here's something that I use (only while developing a program. once exception types are determined, you should use actual exception name)
this will display what type of exception is being thrown.
Never leave this in a finished program, it's way too broad.
you need to import sys, as it's used to identify the exception:
import sys

# ... somewhere in your code ...
    try:
        # code goes here
    except:
        print("Unexpected error:", sys.exc_info()[0])
Reply


Messages In This Thread
RE: Problems with not having exceptions crash my script - by Larz60+ - Feb-16-2018, 07:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problems passing arguments containing spaces to bash script and then on to python kaustin 6 486 Apr-03-2024, 08:26 PM
Last Post: deanhystad
  PiCamera - print exceptions? korenron 2 870 Dec-15-2022, 10:48 PM
Last Post: Larz60+
  Class exceptions DPaul 1 1,324 Mar-11-2022, 09:01 AM
Last Post: Gribouillis
  Catching a crash within a library code ebolisa 9 3,255 Nov-22-2021, 11:02 AM
Last Post: bowlofred
  Python Crash Course ( 2nd edition) alok 1 1,919 Jul-19-2021, 05:55 PM
Last Post: snippsat
  is this a good way to catch exceptions? korenron 14 4,791 Jul-05-2021, 06:20 PM
Last Post: hussaind
  Python, exceptions KingKhan248 6 3,099 Nov-15-2020, 06:54 AM
Last Post: buran
  Split string between two different delimiters, with exceptions DreamingInsanity 2 2,062 Aug-24-2020, 08:23 AM
Last Post: DreamingInsanity
  handling 2 exceptions at once Skaperen 2 2,340 Jun-27-2020, 08:55 AM
Last Post: Yoriz
  remove spaces with exceptions catosp 4 2,457 May-29-2020, 09:32 AM
Last Post: catosp

Forum Jump:

User Panel Messages

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