Skip to content

Conversation

@moutonjeremy
Copy link
Member

Enhance error handling in the custom error handler and Method function to manage serialization failures. Add tests to verify behavior when encountering unserializable outputs and errors.

Copilot AI review requested due to automatic review settings January 2, 2026 18:33
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 enhances error handling in the fiberoapi library to gracefully manage serialization failures when converting responses and errors to JSON. The changes ensure that when unserializable data structures (like channels) are returned, the API returns appropriate error responses instead of failing silently.

Key Changes:

  • Added error handling for serialization failures in the Method function to return structured error responses
  • Enhanced handleCustomError to catch and handle serialization failures of custom error objects
  • Added comprehensive test coverage for both response and error serialization failures

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
serialization_error_test.go New test file with two test cases verifying behavior when encountering unserializable outputs (channels) in both success responses and error responses
fiberoapi.go Modified Method function to check for JSON serialization errors and return a structured ErrorResponse with type "serialization_error" when serialization fails
common.go Enhanced handleCustomError function to catch serialization failures and return a fallback error response with a simple message

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

@moutonjeremy moutonjeremy merged commit 1fd200a into main Jan 2, 2026
4 checks passed
@moutonjeremy moutonjeremy deleted the fix-serialize-error-return branch January 2, 2026 18:43
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