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

     1  package block
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/Microsoft/azure-vhd-utils/vhdcore/footer"
     7  )
     8  
     9  // DataReadError is the error type representing block data read error.
    10  //
    11  type DataReadError struct {
    12  	BlockIndex uint32
    13  	DiskType   footer.DiskType
    14  	err        error
    15  }
    16  
    17  // Error returns the string representation  of the BlockDataReadError instance.
    18  //
    19  func (e *DataReadError) Error() string {
    20  	return fmt.Sprintf("Error in Reading block  '%d', DiskType - %s  : %s", e.BlockIndex, e.DiskType, e.err)
    21  }
    22  
    23  // GetInnerErr returns the inner error, this method satisfies InnerErr interface
    24  //
    25  func (e *DataReadError) GetInnerErr() error {
    26  	return e.err
    27  }
    28  
    29  // NewDataReadError returns a new DataReadError instance.
    30  // The parameter blockIndex represents index of the block whose bitmap failed to parse
    31  // The parameter err is the underlying error for parse failure.
    32  //
    33  func NewDataReadError(blockIndex uint32, diskType footer.DiskType, err error) error {
    34  	return &DataReadError{
    35  		BlockIndex: blockIndex,
    36  		DiskType:   diskType,
    37  		err:        err,
    38  	}
    39  }