Skip to content

feat: enhance exception handling with standardized error codes#155

Open
ArnabChatterjee20k wants to merge 2 commits intomainfrom
migration-error-codes
Open

feat: enhance exception handling with standardized error codes#155
ArnabChatterjee20k wants to merge 2 commits intomainfrom
migration-error-codes

Conversation

@ArnabChatterjee20k
Copy link
Contributor

@ArnabChatterjee20k ArnabChatterjee20k commented Mar 9, 2026

Added new constants for common HTTP error codes in the Exception class. Updated various parts of the codebase to utilize these constants for improved error handling, including specific validation and internal error messages in the Appwrite, JSON, and CSV source and destination classes.

Summary by CodeRabbit

  • Bug Fixes

    • Migration failures now produce clearer, consistent error codes and preserved error context for validation, authorization, transfer, and HTTP errors—improving diagnostics and actionable messages.
  • Refactor

    • Unified exception handling across migration sources and destinations to retain original error codes and chain underlying errors for more reliable troubleshooting.

Added new constants for common HTTP error codes in the Exception class. Updated various parts of the codebase to utilize these constants for improved error handling, including specific validation and internal error messages in the Appwrite, JSON, and CSV source and destination classes.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d005bc6f-5be1-44d6-9e6c-b8bdd221a54f

📥 Commits

Reviewing files that changed from the base of the PR and between cd91e11 and 864a351.

📒 Files selected for processing (1)
  • src/Migration/Sources/Appwrite.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Migration/Sources/Appwrite.php

Walkthrough

Adds HTTP-like error code constants to Migration\Exception and updates exception construction across migration sources, destinations, and Target to include explicit numeric codes and preserve original exceptions as previous throwables. Specific changes set CODE_VALIDATION, CODE_INTERNAL, and other codes on validation, encoding, transfer, and HTTP error cases in CSV, JSON, Appwrite, and Target logic. Also sets a MigrationException code on JSON encoding failures. Messages and control flow are preserved while exceptions carry structured codes and proper chaining.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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 objective of the PR: adding standardized error codes to exception handling across multiple migration classes.
Docstring Coverage ✅ Passed Docstring coverage is 90.91% which is sufficient. The required threshold is 80.00%.

✏️ 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 migration-error-codes

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Migration/Sources/Appwrite.php`:
- Around line 209-213: The 403 branch currently throws a new Exception without
preserving the original code or previous exception; update the branch in
Appwrite.php so the thrown exception includes the 403 status code and the
original exception as the previous (mirror how the else branch forwards
$e->getCode() and $e as previous). Locate the conditional that checks if
($e->getCode() === 403) and change the throw to include the code and $e as the
previous exception so callers see the standardized code and original stack.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd4a39a7-c212-4cf1-995d-91ad6eeed953

📥 Commits

Reviewing files that changed from the base of the PR and between c2d0169 and cd91e11.

📒 Files selected for processing (7)
  • src/Migration/Destinations/Appwrite.php
  • src/Migration/Destinations/JSON.php
  • src/Migration/Exception.php
  • src/Migration/Sources/Appwrite.php
  • src/Migration/Sources/CSV.php
  • src/Migration/Sources/JSON.php
  • src/Migration/Target.php

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.

1 participant