github.com/wrdlbrnft/go-gitignore@v0.0.0-20201129201858-74ef740b8b77/error.go (about)

     1  package gitignore
     2  
     3  type Error interface {
     4  	error
     5  
     6  	// Position returns the position of the error within the .gitignore file
     7  	// (if any)
     8  	Position() Position
     9  
    10  	// Underlying returns the underlying error, permitting direct comparison
    11  	// against the wrapped error.
    12  	Underlying() error
    13  }
    14  
    15  type err struct {
    16  	error
    17  	_position Position
    18  } // err()
    19  
    20  // NewError returns a new Error instance for the given error e and position p.
    21  func NewError(e error, p Position) Error {
    22  	return &err{error: e, _position: p}
    23  } // NewError()
    24  
    25  func (e *err) Position() Position { return e._position }
    26  
    27  func (e *err) Underlying() error { return e.error }
    28  
    29  // ensure err satisfies the Error interface
    30  var _ Error = &err{}