-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfulldebug.py
More file actions
27 lines (23 loc) · 949 Bytes
/
fulldebug.py
File metadata and controls
27 lines (23 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import logging
import pdb
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s', filename='app.log')
def divide_numbers(a, b):
pdb.set_trace() # Set breakpoint for debugging
try:
result = a / b
logging.info(f"Division successful: {a} / {b} = {result}")
return result
except ZeroDivisionError:
logging.error("Attempted to divide by zero.")
print("Error: Cannot divide by zero.")
except TypeError:
logging.error("Invalid types provided for division.")
print("Error: Please enter numeric values.")
except Exception as e:
logging.exception("An unexpected error occurred.")
print("An unexpected error occurred.")
# Testing different scenarios
divide_numbers(10, 2) # Successful division
divide_numbers(10, 0) # Division by zero
divide_numbers(10, 'a') # Type error