Skip to content

Commit

Permalink
MAINT: Fix generic except block bad practice
Browse files Browse the repository at this point in the history
  • Loading branch information
giovaniceotto committed Jan 13, 2023
1 parent 93f65a9 commit 7c33fbf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions rocketpy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
__copyright__ = "Copyright 20XX, RocketPy Team"
__license__ = "MIT"

import traceback
import warnings

import numpy as np
from scipy.integrate import solve_ivp

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

0 comments on commit 7c33fbf

Please sign in to comment.