aboutsummaryrefslogtreecommitdiff
path: root/hotline/transfer.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-07-25 17:00:43 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-07-25 17:00:43 -0700
commit6e4935b32843d1007b1070275d4e99edb345d6bc (patch)
treebd1a815086b171c48e8c7a1a7df79107c4f7d8f3 /hotline/transfer.go
parent23c1295a4d9b13fdb955d2041a49b9b5d6daa060 (diff)
Wrap file transfer errors with more context
Diffstat (limited to 'hotline/transfer.go')
-rw-r--r--hotline/transfer.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/hotline/transfer.go b/hotline/transfer.go
index 5cb28c8..53dd356 100644
--- a/hotline/transfer.go
+++ b/hotline/transfer.go
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"errors"
+ "fmt"
"io"
)
@@ -31,26 +32,26 @@ func (tf *transfer) Write(b []byte) (int, error) {
func receiveFile(r io.Reader, targetFile, resForkFile, infoFork, counterWriter io.Writer) error {
var ffo flattenedFileObject
if _, err := ffo.ReadFrom(r); err != nil {
- return err
+ return fmt.Errorf("read flatted file object: %v", err)
}
// Write the information fork
_, err := io.Copy(infoFork, &ffo.FlatFileInformationFork)
if err != nil {
- return err
+ return fmt.Errorf("write the information fork: %v", err)
}
if _, err = io.CopyN(targetFile, io.TeeReader(r, counterWriter), ffo.dataSize()); err != nil {
- return err
+ return fmt.Errorf("copy file data to partial file: %v", err)
}
if ffo.FlatFileHeader.ForkCount == [2]byte{0, 3} {
if err := binary.Read(r, binary.BigEndian, &ffo.FlatFileResForkHeader); err != nil {
- return err
+ return fmt.Errorf("read resource fork header: %v", err)
}
if _, err = io.CopyN(resForkFile, io.TeeReader(r, counterWriter), ffo.rsrcSize()); err != nil {
- return err
+ return fmt.Errorf("read resource fork: %v", err)
}
}
return nil