nix-amer/internal/cnf/parser/nginx/errors.go

35 lines
1.0 KiB
Go
Raw Normal View History

package nginx
import (
"fmt"
2018-11-13 12:10:55 +00:00
"github.com/xdrm-brackets/nix-amer/internal/clifmt"
)
// ErrNullReceiver is raised when a null receiver is provided
var ErrNullReceiver = fmt.Errorf("receiver must not be null")
// ErrInvalidReceiver is raised when an invalid receiver is provided
var ErrInvalidReceiver = fmt.Errorf("receiver must be compatible with *Line")
// ErrUnexpectedSectionClose is raised when reading a section close '}' without an
// open section
var ErrUnexpectedSectionClose = fmt.Errorf("unexpected section close")
// ErrUnclosedSection is raised when there is unclosed sections reaching the end
// of the file
var ErrUnclosedSection = fmt.Errorf("unclosed section")
// ErrInvalidSyntax is raised when a line cannot be understood
var ErrInvalidSyntax = fmt.Errorf("invalid syntax")
// LineError wraps errors with a line index
type LineError struct {
Line int
Err error
}
// Error implements Error
func (le LineError) Error() string {
return fmt.Sprintf(":%d %s", le.Line, clifmt.Color(31, le.Err.Error()))
}