nix-amer/internal/instruction/errors.go

29 lines
794 B
Go
Raw Normal View History

package instruction
import (
2018-11-14 21:10:31 +00:00
"fmt"
)
// ErrInvalidAlias is raised when encountering an invalid token in an alias name
2018-11-14 21:10:31 +00:00
var ErrInvalidAlias = fmt.Errorf("invalid alias name (contains '/')")
2018-11-11 18:01:00 +00:00
// ErrInvalidSyntax is raised when encountering an invalid token
2018-11-14 21:10:31 +00:00
var ErrInvalidSyntax = fmt.Errorf("invalid instruction format")
2018-11-11 18:01:00 +00:00
// 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
2018-11-14 21:10:31 +00:00
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)
}