github.com/Microsoft/azure-vhd-utils@v0.0.0-20230613175315-7c30a3748a1b/vhdcore/block/sectorReadError.go (about)

     1  package block
     2  
     3  import "fmt"
     4  
     5  // SectorReadError is the error type representing block's sector read error.
     6  //
     7  type SectorReadError struct {
     8  	BlockIndex  uint32
     9  	SectorIndex uint32
    10  	err         error
    11  }
    12  
    13  // Error returns the string representation  of the SectorReadError instance.
    14  //
    15  func (e *SectorReadError) Error() string {
    16  	return fmt.Sprintf("Read sector '%d' of block '%d' failed: %s", e.SectorIndex, e.BlockIndex, e.err)
    17  }
    18  
    19  // NewSectorReadError returns a new SectorReadError instance.
    20  // The parameter blockIndex represents index of the block
    21  // The parameter sectorIndex represents index of the sector within the block
    22  // The parameter err is the underlying read error.
    23  //
    24  func NewSectorReadError(blockIndex, sectorIndex uint32, err error) error {
    25  	return &SectorReadError{
    26  		BlockIndex:  blockIndex,
    27  		SectorIndex: sectorIndex,
    28  		err:         err,
    29  	}
    30  }