github.com/linuxboot/fiano@v1.2.0/pkg/intel/metadata/fit/check/errors.go (about)

     1  // Copyright 2017-2021 the LinuxBoot Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package check
     6  
     7  import (
     8  	"fmt"
     9  )
    10  
    11  // ErrStartLessThanZero means `startIdx` has negative value
    12  type ErrStartLessThanZero struct {
    13  	StartIdx int
    14  }
    15  
    16  func (err *ErrStartLessThanZero) Error() string {
    17  	return fmt.Sprintf("start index is less than zero: %d", err.StartIdx)
    18  }
    19  
    20  // ErrEndLessThanStart means `endIdx` value is less than `startIdx` value
    21  type ErrEndLessThanStart struct {
    22  	StartIdx int
    23  	EndIdx   int
    24  }
    25  
    26  func (err *ErrEndLessThanStart) Error() string {
    27  	return fmt.Sprintf("end index is less than start index: %d < %d",
    28  		err.EndIdx, err.StartIdx)
    29  }
    30  
    31  // ErrEndGreaterThanLength means `endIdx` is greater or equal to the length.
    32  type ErrEndGreaterThanLength struct {
    33  	Length uint
    34  	EndIdx int
    35  }
    36  
    37  func (err *ErrEndGreaterThanLength) Error() string {
    38  	return fmt.Sprintf("end index is outside of the bounds: %d >= %d",
    39  		err.EndIdx, err.Length)
    40  }