nix-amer/internal/instruction/errors.go

29 lines
794 B
Go

package instruction
import (
"fmt"
)
// ErrInvalidAlias is raised when encountering an invalid token in an alias name
var ErrInvalidAlias = fmt.Errorf("invalid alias name (contains '/')")
// ErrInvalidSyntax is raised when encountering an invalid token
var ErrInvalidSyntax = fmt.Errorf("invalid instruction format")
// ErrUnknownInstruction is raised when encountering an unknown instruction
// it can mean that you're not using the right version or that you've misspelled it
var ErrUnknownInstruction = fmt.Errorf("unknown instruction")
type FileError struct {
Reason string
File string
Err error
}
func (ce FileError) Error() string {
if ce.Err == nil {
return fmt.Sprintf("%s '%s'", ce.Reason, ce.File)
}
return fmt.Sprintf("%s '%s' | %s", ce.Reason, ce.File, ce.Err)
}