All Questions
5,305 questions
0
votes
0
answers
20
views
Python: is there a straightforward way to determine if it is safe to move a line of code outside of a try-except? [duplicate]
Suppose you have some code like this:
def some_func():
try:
func_a()
func_b()
func_c()
except SomeException as e:
print("An exception occurred.")
Is ...
1
vote
0
answers
55
views
When is it better to use if statements versus multiple except blocks (or a mix of both) in Python? [closed]
I came across the following code while refactoring a Python program:
if not Path(file_path).exists():
logging.error(f"File not found: {file_path}")
return {}
try:
with ...
0
votes
1
answer
34
views
How to catch one of many exceptions in the code and keep the original message?
I have an azure function that is currently listening to a topic in event hub.
We receive several json as events, and we need to implement a decorator to wrapp all the possible exceptions that can ...
0
votes
0
answers
15
views
configuring karrigell logging to log uncaught exceptions
I am managing a third-part app made with python's framework Karrigell.
I have added a new logger, my_logger, which is declared and instantiated in a file called my_logging.py
I see that the logger can ...
0
votes
1
answer
52
views
NotImplementedError when using threading with a keyboard and mouse listener with pynput
Here is the keyboard and mouse listener part of my code:
python
def mouse_listener(scroller):
"""Listens for mouse scroll events to scroll clipboard history."""
...
1
vote
1
answer
43
views
Can Polars with calamine engine be coerced into failing more gracefully?
I have 10s of thousands of excel files to which I'm applying validation using Polars. Some excel files have a problem that spawns an index out of bounds panic in the py03 runtime, when using engine=...
0
votes
1
answer
37
views
How do I properly handle exceptions in Python without losing the traceback information?
I'm working on a Python application where I need to gracefully handle exceptions and log useful information for debugging purposes. Specifically, I want to catch exceptions that occur during runtime, ...
0
votes
1
answer
76
views
Airflow DAG to retry if any of the Airflow Tasks fails
Would like to ask a Airflow question , currently when we set on the DAG default args to retry 5 times
if failure happens
default_args = {
'owner': 'testing',
'retries': 5,
'...
0
votes
1
answer
59
views
How to print errors like python does by default?
Considering the following errornous function:
def inner():
raise Exception("message")
If I run the function I get an error like:
Traceback (most recent call last):
File "/...
0
votes
0
answers
42
views
Different errors with and without exception handling (Python psycopg2 UniqueViolation vs InternalError) [duplicate]
I'm familiar with coding and bit of front and backend development on existing projects, but fairly new to Python and postgreSql. I'm transferring 60GB or so of .csv files into a postgres db. I've been ...
-1
votes
1
answer
35
views
Problem with load more button. Always getting stale element. How to deal with it?
I have a simple program that get to result's page, click product by product and scrape the information on product's page. There is one site that has the load more button. So the approach I'm trying to ...
0
votes
0
answers
15
views
How can I improve exception handling in the check_domain method of the MVT tool?
I’m working with the MVT (Mobile Verification Toolkit) tool and noticed that the check_domain method uses a broad except Exception block. This approach can lead to false positives when checking for ...
1
vote
2
answers
53
views
undefined error not raising NameError and program runs fine
Why is my code here not raising a NameError or Syntax error when I clearly am using non existing error name?
def fun(x):
assert x >= 0
return x ** 0.5
def mid_level(x):
try:
...
1
vote
1
answer
63
views
Raising python exception from native thread
I have a C++ class Runner that encapsulates running a native thread. This class is exposed to Python via pybind11, so start_thread is called from Python.
class Runner {
public:
void start_thread() ...
0
votes
0
answers
21
views
Exception on PCANBasic.Read
I am using the python PCAN Basic api and when I connect to my CAN network, I keep getting a message that says Exception on PCANBasic.Read. The code that is catching this exception is:
try:
...