Skip to content

Conversation

@EricccTaiwan
Copy link
Contributor

The previous implementation allocated a temporary Vector and multiple Strings just to format the context map. This commit switches to a streaming approach using write!, which writes directly to the formatter without heap allocations.

No functional changes.

@tisonkun PTAL, thanks.

The previous implementation allocated a temporary Vector and multiple Strings
just to format the context map. This commit switches to a streaming approach
using `write!`, which writes directly to the formatter without heap allocations.

No functional changes.

Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

Look reasonable. Would you add a test to guard the output stay the same?

That is, add a (snapshot) test assert the output format (error with context) so that further refactoring can be easilier reviewed.

@EricccTaiwan EricccTaiwan requested a review from tisonkun January 29, 2026 02:19
@tisonkun tisonkun enabled auto-merge (squash) January 29, 2026 02:28
Introduces unit tests to verify the correctness of the `Display`
implementation for the `Error` struct.

The new tests cover:
1. Basic error messages without context.
2. Complex messages with multiple context items.

Suggested-by: @tisonkun
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
auto-merge was automatically disabled January 29, 2026 02:37

Head branch was pushed to by a user without write access

@EricccTaiwan EricccTaiwan force-pushed the refactor-error-handling branch from c54f58a to 7d63c1d Compare January 29, 2026 02:37
@tisonkun tisonkun enabled auto-merge (squash) January 29, 2026 03:11
@tisonkun tisonkun merged commit 493132c into apache:main Jan 29, 2026
9 checks passed
@tisonkun tisonkun mentioned this pull request Jan 29, 2026
@EricccTaiwan EricccTaiwan deleted the refactor-error-handling branch January 29, 2026 06: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