Skip to content

feat: add InvalidPeriodException for NameCom adapter#62

Merged
ChiragAgg5k merged 1 commit intomasterfrom
add-invalid-period-exception
Mar 3, 2026
Merged

feat: add InvalidPeriodException for NameCom adapter#62
ChiragAgg5k merged 1 commit intomasterfrom
add-invalid-period-exception

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Mar 3, 2026

Summary

  • Add InvalidPeriodException thrown when NameCom API returns "Invalid value for years" (HTTP 400)
  • Order ERROR_INVALID_YEARS before ERROR_INVALID_CONTACT in ERROR_MAP so the more specific pattern matches first (both share the 'invalid value for' substring)
  • Add error code 400 to the map entry for precise matching

Test plan

  • testGetPriceWithInvalidPeriod passes — confirms InvalidPeriodException is thrown for invalid year values

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced domain registrar validation to properly detect and handle invalid registration periods with clear error responses, preventing failed transactions.
  • Tests

    • Added test coverage to verify correct error handling and messaging when invalid domain registration periods are encountered.

Throw InvalidPeriodException when the API returns an invalid years
error (HTTP 400). Ordered ERROR_INVALID_YEARS before
ERROR_INVALID_CONTACT in ERROR_MAP so the more specific pattern
matches first.
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f9191c and 89d725a.

📒 Files selected for processing (3)
  • src/Domains/Registrar/Adapter/NameCom.php
  • src/Domains/Registrar/Exception/InvalidPeriodException.php
  • tests/Registrar/NameComTest.php

Walkthrough

The changes add support for handling invalid domain registration periods in the NameCom registrar adapter. A new exception class InvalidPeriodException is introduced, a new error constant ERROR_INVALID_YEARS is added to the adapter with HTTP 400 mapping, and logic is implemented to throw this exception when invalid years are encountered during price retrieval. A corresponding test verifies this behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change—adding InvalidPeriodException for the NameCom adapter. It is specific, concise, and clearly communicates the primary objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-invalid-period-exception

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChiragAgg5k ChiragAgg5k merged commit 0edf6bb into master Mar 3, 2026
7 of 23 checks passed
@ChiragAgg5k ChiragAgg5k deleted the add-invalid-period-exception branch March 3, 2026 09:20
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