Skip to content

Commit 7c33fbf

Browse files
committed
MAINT: Fix generic except block bad practice
1 parent 93f65a9 commit 7c33fbf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

rocketpy/utilities.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
__copyright__ = "Copyright 20XX, RocketPy Team"
44
__license__ = "MIT"
55

6+
import traceback
7+
import warnings
8+
69
import numpy as np
710
from scipy.integrate import solve_ivp
811

@@ -244,13 +247,14 @@ def create_dispersion_dictionary(filename):
244247
file = np.genfromtxt(
245248
filename, usecols=(1, 2, 3), skip_header=1, delimiter=";", dtype=str
246249
)
247-
except Exception as e:
248-
print(
249-
f"Error {e} caught: the delimiter should be ';'. Using ',' instead, be"
250+
except ValueError:
251+
warnings.warn(
252+
f"Error caught: the recommended delimiter is ';'. If using ',' instead, be "
250253
+ "aware that some resources might not work as expected if your data "
251-
+ "set contains lists where the items are separated by commas."
254+
+ "set contains lists where the items are separated by commas. "
252255
+ "Please consider changing the delimiter to ';' if that is the case."
253256
)
257+
warnings.warn(traceback.format_exc())
254258
file = np.genfromtxt(
255259
filename, usecols=(1, 2, 3), skip_header=1, delimiter=",", dtype=str
256260
)

0 commit comments

Comments
 (0)