Skip to content

Commit

Permalink
changed two exceptions slightly to preserve original traceback
Browse files Browse the repository at this point in the history
  • Loading branch information
Amedeo Paolo Ceruti committed Jan 25, 2024
1 parent 0c5ba67 commit 4f64c52
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tsam/timeseriesaggregation.py
Expand Up @@ -387,21 +387,21 @@ def _check_init_args(self):
try:
timedelta = self.timeSeries.index[1] - self.timeSeries.index[0]
self.resolution = float(timedelta.total_seconds()) / 3600
except AttributeError:
except AttributeError as exc:
raise ValueError(
"'resolution' argument has to be nonnegative float or int"
+ " or the given timeseries needs a datetime index"
)
) from exc
except TypeError:
try:
self.timeSeries.index = pd.to_datetime(self.timeSeries.index)
timedelta = self.timeSeries.index[1] - self.timeSeries.index[0]
self.resolution = float(timedelta.total_seconds()) / 3600
except:
except Exception as exc:
raise ValueError(
"'resolution' argument has to be nonnegative float or int"
+ " or the given timeseries needs a datetime index"
)
) from exc

if not (isinstance(self.resolution, int) or isinstance(self.resolution, float)):
raise ValueError("resolution has to be nonnegative float or int")
Expand Down

0 comments on commit 4f64c52

Please sign in to comment.