github.com/djordje200179/extendedlibrary/datastructures@v1.7.1-0.20240227175559-d09520a92dd4/cols/errors.go (about)

     1  package cols
     2  
     3  import "fmt"
     4  
     5  // IndexOutOfBoundsError is an error that is panicked when trying
     6  // to access an element of a collection with an index that is out of bounds.
     7  type IndexOutOfBoundsError struct {
     8  	Index  int // the index that was out of bounds
     9  	Length int // the length of the collection
    10  }
    11  
    12  // Error returns the error message.
    13  func (err IndexOutOfBoundsError) Error() string {
    14  	return fmt.Sprintf("index %d out of bounds for collection of length %d", err.Index, err.Length)
    15  }