Skip to content

pcapgo: use %w instead of %v when wrapping errors in WritePacket#1234

Open
alliasgher wants to merge 1 commit intogoogle:masterfrom
alliasgher:fix-write-error-wrapping
Open

pcapgo: use %w instead of %v when wrapping errors in WritePacket#1234
alliasgher wants to merge 1 commit intogoogle:masterfrom
alliasgher:fix-write-error-wrapping

Conversation

@alliasgher
Copy link
Copy Markdown

Fixes #1213. Switch from %v to %w in the WritePacket error return so that errors.Is and errors.As can match the underlying system error (e.g. syscall.ENOSPC).

fmt.Errorf with %v loses the original error, preventing errors.Is and
errors.As from matching the underlying cause (e.g. syscall.ENOSPC).
Switch to %w so callers can inspect wrapped errors.

Fixes google#1213

Signed-off-by: alliasgher <alliasgher123@gmail.com>
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.

WritePacket does not properly wrap errors, breaking errors.Is detection (should use %w not %v)

1 participant