Skip to content

Conversation

@drlucaa
Copy link
Member

@drlucaa drlucaa commented Nov 24, 2025

  • Add public Metadata() method to *Error struct that returns a copy of metadata as map[string]any
  • Include comprehensive tests for the new method including immutability verification
  • Update README with documentation and usage examples for the Metadata() method
  • Convert interface{} to any in tests for Go 1.18+ compatibility

This allows external consumers to inspect the structured context attached to errors while maintaining immutability and performance principles of the library.

- Add public Metadata() method to *Error struct that returns a copy of metadata as map[string]any
- Include comprehensive tests for the new method including immutability verification
- Update README with documentation and usage examples for the Metadata() method
- Convert interface{} to any in tests for Go 1.18+ compatibility

This allows external consumers to inspect the structured context attached to errors while maintaining immutability and performance principles of the library.
@drlucaa drlucaa requested a review from Copilot November 24, 2025 17:57
Copy link

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 adds a Metadata() method to the *Error type, enabling external consumers to inspect structured context attached to errors. The method returns an immutable copy of the metadata as map[string]any, ensuring that modifications to the returned map don't affect the error's internal state.

Key changes:

  • New Metadata() method on *Error that returns a defensive copy of metadata
  • Comprehensive test coverage including immutability verification
  • Documentation and usage examples added to README

Reviewed changes

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

File Description
zerr.go Implements the new Metadata() method with defensive copying
zerr_test.go Adds tests for metadata access and immutability; updates type from interface{} to any
README.md Documents the new Metadata() method with usage examples

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

@drlucaa drlucaa merged commit 351c8fb into main Nov 24, 2025
1 check passed
@drlucaa drlucaa deleted the feature/metadata-accessor branch November 24, 2025 18:00
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