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