Drop redundant Err field from unsupportedVersionError · Entire

Drop redundant Err field from unsupportedVersionError

2427edd→main·pfleidi·3w ago·1 file·+2 added/-4 removed

The field always held the package sentinel errUnsupportedVersion and was read only by this type's Error and Unwrap methods. Wire both to the sentinel directly so the error carries only its per-instance context (checkpoint ID and version). The error string and errors.Is chain are unchanged.

Sessions

35a0d0ce56a6View transcript

Changes

1

25 unmodified lines

26
27
28
29
29
30
31
2 unmodified lines

34
35
36
38
37
38
39
42
40
41
42
43
46
44
45

25 unmodified lines

return unsupportedVersionError{
            CheckpointID: checkpointID,
            Version:      version,
            Err:          errUnsupportedVersion,
        }
    }
    return nil
2 unmodified lines

type unsupportedVersionError struct {
    CheckpointID string
    Version      string
    Err          error
}

func (e unsupportedVersionError) Error() string {
    return fmt.Sprintf("checkpoint %s uses unsupported checkpoint_version %q: %v", e.CheckpointID, e.Version, e.Err)
    return fmt.Sprintf("checkpoint %s uses unsupported checkpoint_version %q: %v", e.CheckpointID, e.Version, errUnsupportedVersion)
}

func (e unsupportedVersionError) Unwrap() error {
    return e.Err
    return errUnsupportedVersion
}

Mcmd/entire/cli/checkpointpolicy/version.go+2/-4