refactor: return errors with stack traces, where appropriate
1 file changed, 10 insertions(+), 4 deletions(-)
changed files
M internal/multifile/compress.go → internal/multifile/compress.go
@@ -1,9 +1,10 @@ package multifile import ( - "errors" "io" "os" + + "gitlab.com/tozd/go/errors" ) type CompressWriter struct {@@ -18,10 +19,15 @@ Writer: writer, } } -func (cw *CompressWriter) Write(p []byte) (n int, err error) { - return cw.Writer.Write(p) +func (cw *CompressWriter) Write(p []byte) (int, error) { + n, err := cw.Writer.Write(p) + if err != nil { + return 0, errors.WithStack(err) + } + + return n, nil } func (cw *CompressWriter) Close() error { - return errors.Join(cw.Writer.Close(), cw.File.Close()) + return errors.WithStack(errors.Join(cw.Writer.Close(), cw.File.Close())) }