Skip to content

[FIX] Use specific exception types in date_features#833

Open
K2alyan wants to merge 1 commit into
Nixtla:mainfrom
K2alyan:fix/date-features-exception-types
Open

[FIX] Use specific exception types in date_features#833
K2alyan wants to merge 1 commit into
Nixtla:mainfrom
K2alyan:fix/date-features-exception-types

Conversation

@K2alyan

@K2alyan K2alyan commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • Replace raise Exception(...) with raise ValueError(...) when a user passes an unsupported country code to CountryHolidays
  • Replace raise Exception(...) with raise ImportError(...) from e when the optional holidays package is not installed, preserving the original exception chain
  • Add a test test_country_holidays_invalid_country that verifies the ValueError path

Motivation

Generic Exception makes it hard for callers to handle errors specifically. ValueError is the right type for invalid input (a bad country code), and ImportError is the right type for a missing dependency. This also chains the original ModuleNotFoundError so the traceback retains the root cause.

Test plan

  • Run pytest nixtla_tests/date_features/ — all three tests should pass
  • The new test test_country_holidays_invalid_country verifies the ValueError is raised when an invalid country code is provided

Replace generic Exception raises with ValueError (invalid country code)
and ImportError (missing holidays package), and add a test that verifies
the ValueError path.
@CLAassistant

CLAassistant commented Jul 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants