Fix exception causes in 2 modules (#1370)

Co-authored-by: Ben Letham <bletham@gmail.com>
This commit is contained in:
Ram Rachum 2020-03-04 03:34:06 +02:00 committed by GitHub
parent 5842935f41
commit 952b544928
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -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'])

View file

@ -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