Commit cfbb604
authored
fix(pop3): wrap underlying errors (#1320)
## What?
`findAttachmentData` in `backend/pop3/pop3.go` had three error sites
that dropped underlying context:
- `gomail.CreateReader` returned an error but the wrapping call
discarded it with a static `"not a multipart message"` string.
- The `mr.NextPart()` loop broke on a non-EOF error without saving it,
so the final return at the bottom of the function reported "not found"
instead of the real read failure.
- The not-found error had no count of how many parts the loop actually
scanned, which made the failure hard to debug from a log line alone.
This PR wraps the `CreateReader` error with `%w`, captures the
`NextPart` error in a local `scanErr` and surfaces it as the final error
when it is set, and includes the scanned-parts count in the not-found
message.
## Why?
Fixes #688. The reporter noted the missing `%w` wrapping at the original
line 438. While poking at that site I noticed the silent `break` on
`mr.NextPart()` errors right above it. Those two paths share the same
downstream "not found" return, so a multipart parse error in the middle
of the stream looks identical to a genuinely missing part. The third
change (scanned-parts count) is the smallest possible nudge that makes
the two failure modes distinguishable in an error string without
changing the return type or call sites.
Fixes #6881 parent 2642736 commit cfbb604
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
| 468 | + | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
| 472 | + | |
472 | 473 | | |
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
476 | 477 | | |
477 | 478 | | |
| 479 | + | |
478 | 480 | | |
479 | 481 | | |
480 | 482 | | |
| |||
484 | 486 | | |
485 | 487 | | |
486 | 488 | | |
487 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
488 | 494 | | |
0 commit comments