From 952b5449285abbd1ecf655dd8ef3bb782609b077 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Wed, 4 Mar 2020 03:34:06 +0200 Subject: [PATCH] Fix exception causes in 2 modules (#1370) Co-authored-by: Ben Letham --- python/fbprophet/make_holidays.py | 8 ++++---- python/fbprophet/models.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/fbprophet/make_holidays.py b/python/fbprophet/make_holidays.py index 7da7095..27b3c49 100644 --- a/python/fbprophet/make_holidays.py +++ b/python/fbprophet/make_holidays.py @@ -34,9 +34,9 @@ def get_holiday_names(country): except AttributeError: try: holiday_names = getattr(hdays_part1, country)(years=years).values() - except AttributeError: + except AttributeError as e: raise AttributeError( - "Holidays in {} are not currently supported!".format(country)) + "Holidays in {} are not currently supported!".format(country)) from e return set(holiday_names) @@ -58,9 +58,9 @@ def make_holidays_df(year_list, country, province=None): except AttributeError: try: holidays = getattr(hdays_part1, country)(prov=province,years=year_list) - except AttributeError: + except AttributeError as e: raise AttributeError( - "Holidays in {} are not currently supported!".format(country)) + "Holidays in {} are not currently supported!".format(country)) from e holidays_df = pd.DataFrame(list(holidays.items()), columns=['ds', 'holiday']) holidays_df.reset_index(inplace=True, drop=True) holidays_df['ds'] = pd.to_datetime(holidays_df['ds']) diff --git a/python/fbprophet/models.py b/python/fbprophet/models.py index de03333..dc77a6b 100644 --- a/python/fbprophet/models.py +++ b/python/fbprophet/models.py @@ -271,5 +271,5 @@ class StanBackendEnum(Enum): def get_backend_class(name: str) -> IStanBackend: try: return StanBackendEnum[name].value - except KeyError: - raise ValueError("Unknown stan backend: {}".format(name)) + except KeyError as e: + raise ValueError("Unknown stan backend: {}".format(name)) from e