Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WhoisDomainNotFoundError and WhoisUnknownDateFormatError #267

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

Misiu
Copy link
Contributor

@Misiu Misiu commented Jan 27, 2025

I've added two errors.
When a domain is not found in the registry we throw WhoisDomainNotFoundError. This error extends WhoisError, which extends PywhoisError for backward compatibility.
WhoisUnknownDateFormatError is thrown when we can't parse dates.
I've also added data_preprocessor as an optional parameter to WhoisEntry class. This way we can preprocess date strings before they are passed to the parser.
For example, for .cl domains we remove the timezone using:

lambda x: x.replace(" CLST", "").replace(" CLT", "")

@richardpenman richardpenman merged commit b3e0122 into richardpenman:master Jan 27, 2025
5 checks passed
@richardpenman
Copy link
Owner

Looks good! Ideally there would be some tests that cover the exception types - maybe could do that when add support for the other exception types?

@Misiu
Copy link
Contributor Author

Misiu commented Jan 27, 2025

I can try, but as mentioned, I'm still new to Python.
Mind creating the first test showing how to test throwing exceptions, this way I'll try to add new error types with tests

@richardpenman
Copy link
Owner

Here is an example showing how to test for an exception in a unit test:
https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises

@Misiu Misiu deleted the more-errors branch January 28, 2025 11:00
@Misiu
Copy link
Contributor Author

Misiu commented Jan 28, 2025

@richardpenman I did something like this in #268

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