Skip to content

Commit 709d19b

Browse files
committed
Avoid to broad try/except
1 parent 1a9d554 commit 709d19b

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

windpowerlib/wind_farm.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class WindFarm(object):
9999
>>> example_farm = wind_farm.WindFarm(wind_turbine_fleet)
100100
>>> print(example_farm.nominal_power)
101101
31200000.0
102-
103102
"""
104103

105104
def __init__(self, wind_turbine_fleet, efficiency=None, name='', **kwargs):
@@ -128,7 +127,7 @@ def check_and_complete_wind_turbine_fleet(self):
128127
if isinstance(self.wind_turbine_fleet, list):
129128
try:
130129
self.wind_turbine_fleet = pd.DataFrame(self.wind_turbine_fleet)
131-
except:
130+
except ValueError:
132131
raise ValueError("Wind turbine fleet not provided properly.")
133132

134133
# check wind turbines
@@ -165,7 +164,7 @@ def check_and_complete_wind_turbine_fleet(self):
165164
else:
166165
self.wind_turbine_fleet.loc[ix, 'number_of_turbines'] = \
167166
number_of_turbines
168-
except:
167+
except ValueError:
169168
raise ValueError(msg.format(row['wind_turbine']))
170169

171170
# calculate total capacity if necessary and check that total capacity
@@ -176,7 +175,7 @@ def check_and_complete_wind_turbine_fleet(self):
176175
self.wind_turbine_fleet.loc[ix, 'total_capacity'] = \
177176
row['number_of_turbines'] * \
178177
row['wind_turbine'].nominal_power
179-
except:
178+
except ValueError:
180179
raise ValueError(
181180
'Total capacity of turbines of type {turbine} cannot '
182181
'be deduced. Please check if the nominal power of the '

0 commit comments

Comments
 (0)