Improve error handling a bit
Include more details in the returned error text. Don't continue in tests when we fail to obtain a TOC. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
b5413c2bd6
commit
70b2454cde
|
|
@ -201,7 +201,7 @@ func readZstdChunkedManifest(blobStream ImageSourceSeekable, tocDigest digest.Di
|
|||
|
||||
decodedBlob, err := decodeAndValidateBlob(manifest, manifestLengthUncompressed, tocDigest.String())
|
||||
if err != nil {
|
||||
return nil, nil, nil, 0, err
|
||||
return nil, nil, nil, 0, fmt.Errorf("validating and decompressing TOC: %w", err)
|
||||
}
|
||||
toc, err := unmarshalToc(decodedBlob)
|
||||
if err != nil {
|
||||
|
|
@ -217,7 +217,7 @@ func readZstdChunkedManifest(blobStream ImageSourceSeekable, tocDigest digest.Di
|
|||
|
||||
decodedTarSplit, err = decodeAndValidateBlob(tarSplit, tarSplitLengthUncompressed, toc.TarSplitDigest.String())
|
||||
if err != nil {
|
||||
return nil, nil, nil, 0, err
|
||||
return nil, nil, nil, 0, fmt.Errorf("validating and decompressing tar-split: %w", err)
|
||||
}
|
||||
}
|
||||
return decodedBlob, toc, decodedTarSplit, int64(manifestChunk.Offset), err
|
||||
|
|
@ -226,7 +226,7 @@ func readZstdChunkedManifest(blobStream ImageSourceSeekable, tocDigest digest.Di
|
|||
func decodeAndValidateBlob(blob []byte, lengthUncompressed uint64, expectedCompressedChecksum string) ([]byte, error) {
|
||||
d, err := digest.Parse(expectedCompressedChecksum)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("invalid digest %q: %w", expectedCompressedChecksum, err)
|
||||
}
|
||||
|
||||
blobDigester := d.Algorithm().Digester()
|
||||
|
|
|
|||
|
|
@ -155,9 +155,7 @@ func TestGenerateAndParseManifest(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.NotNil(t, tocDigest)
|
||||
manifest, decodedTOC, _, _, err := readZstdChunkedManifest(s, *tocDigest, annotations)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
require.NoError(t, err)
|
||||
|
||||
var toc internal.TOC
|
||||
if err := json.Unmarshal(manifest, &toc); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue