try-except

Cannot catch requests.exceptions.ConnectionError with try except

Cannot catch requests.exceptions.ConnectionError with try except Question: It feels like I am slowly losing my sanity. I am unable to catch a connection error in a REST-API request. I read at least 20 similar questions on stackoverflow, tried every possible except statement I could think of and simplified the code as much as I could …

Total answers: 1

How to fix "During handling of the above exception, another exception occurred: "

How to fix "During handling of the above exception, another exception occurred: " Question: How do i fix this error, whenever i enter data that should cause an exception more than once the program crashes. Here is my code and what it outputs, it should keep repeating until correct data is entered. code flag=False while …

Total answers: 1

Python Try/Except function

Python Try/Except function Question: I just can’t find others with the same problem. Im sure they exist but im not having luck and this is my very first time learning a language. My try/except works when i enter the wrong type of value. However, it does not work when i enter the correct type of …

Total answers: 3

Looking for an alternative for nested try-except block in python

Looking for an alternative for nested try-except block in python Question: I was making an image resizing program using the pillow module in python. I like to program a perfect error-catching program, so I used many nested try-catch blocks in the program below. It works perfectly but I need to modify the code in less …

Total answers: 1

using try-except block to scrape data from twitter api

using try-except block to scrape data from twitter api Question: I’m scraping data from twiter with using their tweet ids but some of the tweets have been deleted so my code throws an error when it gets to those tweets ids how do I use "try-except" to just skip those tweet ids or populate the …

Total answers: 1

How to simplify repetitive try-except blocks

How to simplify repetitive try-except blocks Question: I have the below code that needs to check if the visible property of any of the objects are found. Each of the acronym functions in the try-except blocks return an object reference if found, each with their own visible property. If any of the acronym objects are …

Total answers: 1

How to re-run through loop when exception happens in Python?

How to re-run through loop when exception happens in Python? Question: When executing this it only runs through the initial if elif statement. If I reach 0 it returns the proper print statement along with when I’m subtracting numbers. However if I try to subtract to reach a negative number and therefore reach the exception, …

Total answers: 1

How to define multiple error handling statements?

How to define multiple error handling statements? Question: I would like to read a set of csv files from URL as dataframes. These files contain a date in their name like YYYYMMDD.csv in their names. I need to iterate over a set of predefined dates and read the corresponding file into a Python. Sometimes the …

Total answers: 3