Skip to content

Commit 85018b9

Browse files
committed
chore: reword errors
1 parent e3a8833 commit 85018b9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pkg/files/file_stream.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ func recvContents(
119119
}
120120
totalSize -= len(data)
121121
if 0 > totalSize {
122-
return fmt.Errorf("unexpected content: %d more data than expected", 0-totalSize)
122+
return fmt.Errorf("unexpected content: %d bytes more data than expected", 0-totalSize)
123123
}
124124
}
125125
if totalSize > 0 {
126-
return fmt.Errorf("unexpected content: unexpected end of content, %d left", totalSize)
126+
return fmt.Errorf("unexpected content: unexpected end of content, expected additional %d bytes", totalSize)
127127
}
128128

129129
return nil
@@ -132,14 +132,16 @@ func recvContents(
132132
func validateRecvChunk(chunk *v1.FileDataChunk, chunkSize, lastChunkIndex, i int) error {
133133
content := chunk.GetContent()
134134
if content == nil {
135-
return fmt.Errorf("no content")
135+
return fmt.Errorf("no content in chunk id %d", i)
136136
}
137137
if content.GetChunkId() != uint32(i) {
138-
return fmt.Errorf("unexpected chunk id %d, expected %d", content.GetChunkId(), i)
138+
return fmt.Errorf("content chunk id of %d does not match expected id of %d",
139+
content.GetChunkId(), i)
139140
}
140141
data := content.GetData()
141142
if len(data) != chunkSize && i != lastChunkIndex {
142-
return fmt.Errorf("content chunk size %d, expected %d", len(data), chunkSize)
143+
return fmt.Errorf("content chunk size of %d does not match expected size of %d",
144+
len(data), chunkSize)
143145
}
144146

145147
return nil

pkg/files/file_stream_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func TestRecvChunkedFile(t *testing.T) {
277277
},
278278
},
279279
// last chunk can be undersized
280-
expectedErrString: "1500 left",
280+
expectedErrString: "expected additional 1500 bytes",
281281
},
282282
{
283283
name: "Test 4: data unmatched - chunks size",
@@ -314,7 +314,7 @@ func TestRecvChunkedFile(t *testing.T) {
314314
},
315315
},
316316
},
317-
expectedErrString: "content chunk size 0, expected 1500",
317+
expectedErrString: "content chunk size of 0 does not match expected size of 1500",
318318
},
319319
{
320320
name: "Test 5: data unmatched - extra",
@@ -353,7 +353,7 @@ func TestRecvChunkedFile(t *testing.T) {
353353
},
354354
},
355355
},
356-
expectedErrString: "1500 more data than expected",
356+
expectedErrString: "unexpected content: 1500 bytes more data than expected",
357357
},
358358
{
359359
name: "Test 6: data unmatched - chunk id",
@@ -382,7 +382,7 @@ func TestRecvChunkedFile(t *testing.T) {
382382
},
383383
},
384384
},
385-
expectedErrString: "unexpected chunk id 5, expected 0",
385+
expectedErrString: "content chunk id of 5 does not match expected id of 0",
386386
},
387387
{
388388
name: "Test 7: content recv error",

0 commit comments

Comments
 (0)