[chore] Prevent panic when ChunkError has a nil Unit (#2227)

This commit is contained in:
Miccah 2023-12-15 11:11:28 -08:00 committed by GitHub
parent b0fab16ad4
commit 78b5a95342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -94,7 +94,11 @@ type ChunkError struct {
}
func (f ChunkError) Error() string {
return fmt.Sprintf("error chunking unit %q: %s", f.Unit.SourceUnitID(), f.Err.Error())
unit := "<nil>"
if f.Unit != nil {
unit = f.Unit.SourceUnitID()
}
return fmt.Sprintf("error chunking unit %q: %s", unit, f.Err.Error())
}
func (f ChunkError) Unwrap() error { return f.Err }