Skip to content

Commit 4f46e8f

Browse files
committed
Extend logging for error collection handling
1 parent 3086b78 commit 4f46e8f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

sections.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ func (p Plugin) handleErrorsSection(w io.Writer) {
5656

5757
var totalWritten int
5858

59-
writeErrorToOutputSink := func(err error) {
59+
writeErrorToOutputSink := func(err error, fieldname string) {
6060
written, writeErr := fmt.Fprintf(w, "* %v%s", err, CheckOutputEOL)
6161
if writeErr != nil {
62-
panic("Failed to write LastError field content to given output sink")
62+
msg := fmt.Sprintf("Failed to write error field %q value to given output sink", fieldname)
63+
panic(msg)
6364
}
6465

6566
totalWritten += written
@@ -79,13 +80,16 @@ func (p Plugin) handleErrorsSection(w io.Writer) {
7980
totalWritten += written
8081

8182
if p.LastError != nil {
82-
writeErrorToOutputSink(p.LastError)
83+
p.logAction("Writing field p.LastError value to output sink")
84+
85+
writeErrorToOutputSink(p.LastError, "p.LastError")
8386
}
8487

8588
// Process any non-nil errors in the collection.
89+
p.logAction(fmt.Sprintf("Writing %d errors from field %q to output sink", len(p.Errors), "p.Errors"))
8690
for _, err := range p.Errors {
8791
if err != nil {
88-
writeErrorToOutputSink(err)
92+
writeErrorToOutputSink(err, "p.Errors")
8993
}
9094
}
9195

0 commit comments

Comments
 (0)