Skip to content

Conversation

@javorosas
Copy link
Member

  • Se agrega propiedad "Status" al objeto de error
  • Se centraliza el manejo de errores en método compartido en BaseWrapper
  • Se eliminan "using"s innecesarios

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves error handling in the Facturapi .NET SDK by adding a "Status" property to the FacturapiException class and centralizing error handling logic in the BaseWrapper class through a new ThrowIfErrorAsync method. This refactoring eliminates code duplication across all wrapper classes.

  • Adds a Status property to FacturapiException to expose HTTP status codes from API errors
  • Introduces centralized error handling through BaseWrapper.ThrowIfErrorAsync and CreateException methods
  • Removes duplicated error handling code from all wrapper classes, replacing it with calls to the shared method

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
FacturAPIException.cs Adds Status property and updates constructor to accept optional status parameter
Wrappers/BaseWrapper.cs Introduces CreateException and ThrowIfErrorAsync methods to centralize error handling logic
Wrappers/WebhookWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Wrappers/ToolWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Wrappers/RetentionWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Wrappers/ReceiptWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Wrappers/ProductWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Wrappers/OrganizationWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports; fixes indentation
Wrappers/InvoiceWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Wrappers/CustomerWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports; fixes indentation
Wrappers/CatalogWrapper.cs Replaces inline error handling with ThrowIfErrorAsync calls; removes unused imports
Comments suppressed due to low confidence (1)

Wrappers/BaseWrapper.cs:43

  • Poor error handling: empty catch block.
            catch (JsonException)
            {
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

javorosas and others added 4 commits December 10, 2025 09:30
…wing

- Updated `FacturapiException` to include an optional status code.
- Introduced `ThrowIfErrorAsync` method in `BaseWrapper` to handle HTTP response errors consistently across all wrappers.
- Removed redundant error handling code from `CatalogWrapper`, `CustomerWrapper`, `InvoiceWrapper`, `OrganizationWrapper`, `ProductWrapper`, `ReceiptWrapper`, `RetentionWrapper`, `ToolWrapper`, and `WebhookWrapper`.
- Ensured all wrappers now utilize the new error handling method for improved maintainability and readability.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…archCatalogAsync for error handling and response parsing
@javorosas javorosas force-pushed the FAC-1703/feat/add-status-field-on-error-object branch from fcee372 to aa21682 Compare December 10, 2025 16:55
@javorosas javorosas merged commit 3fdf83f into main Dec 11, 2025
@javorosas javorosas deleted the FAC-1703/feat/add-status-field-on-error-object branch December 11, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants