File tree Expand file tree Collapse file tree 3 files changed +15
-7
lines changed
Expand file tree Collapse file tree 3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -69,9 +69,7 @@ func (e *Error) Error() string {
6969 parts = append (parts , e .Err .Error ())
7070 }
7171
72- for _ , ctx := range e .Context {
73- parts = append (parts , ctx )
74- }
72+ parts = append (parts , e .Context ... )
7573
7674 return strings .Join (parts , ": " )
7775}
Original file line number Diff line number Diff line change @@ -301,7 +301,10 @@ func (l *logger) logText(level Level, msg string) {
301301 }
302302 }
303303
304- fmt .Fprintln (l .config .Output , output )
304+ if _ , err := fmt .Fprintln (l .config .Output , output ); err != nil {
305+ // If we can't write to the output, try to write to stderr as a fallback
306+ fmt .Fprintf (os .Stderr , "logger: failed to write log: %v\n " , err )
307+ }
305308}
306309
307310// logJSON outputs structured JSON
Original file line number Diff line number Diff line change @@ -85,7 +85,11 @@ func copyFile(src, dst string) error {
8585 if err != nil {
8686 return fmt .Errorf ("failed to open source file: %w" , err )
8787 }
88- defer srcFile .Close ()
88+ defer func () {
89+ if cerr := srcFile .Close (); cerr != nil {
90+ err = fmt .Errorf ("failed to close source file: %w" , cerr )
91+ }
92+ }()
8993
9094 // Get source file info for permissions
9195 srcInfo , err := srcFile .Stat ()
@@ -98,7 +102,11 @@ func copyFile(src, dst string) error {
98102 if err != nil {
99103 return fmt .Errorf ("failed to create destination file: %w" , err )
100104 }
101- defer dstFile .Close ()
105+ defer func () {
106+ if cerr := dstFile .Close (); cerr != nil && err == nil {
107+ err = fmt .Errorf ("failed to close destination file: %w" , cerr )
108+ }
109+ }()
102110
103111 // Copy content
104112 if _ , err := io .Copy (dstFile , srcFile ); err != nil {
@@ -126,4 +134,3 @@ func DefaultFilesWithNVML(root string) []FileSpec {
126134
127135 return filtered
128136}
129-
You can’t perform that action at this time.
0 commit comments