nix-amer/internal/instruction/errors.go

30 lines
840 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")
2018-11-16 05:57:57 +00:00
// FileError is used for file-specific errors
2018-11-14 21:10:31 +00:00
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)
}