nix-amer/internal/instruction/errors.go

30 lines
840 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")
// FileError is used for file-specific errors
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)
}