1
0
mirror of https://github.com/go-task/task.git synced 2025-03-19 21:17:46 +02:00
task/errors/errors_taskfile.go
Pete Davison afe8a618fe
feat: node refactor (#1316)
* refactor: node reader interface

* refactor: rewrite Taskfile() as anon recursive func

* chore: NewNodeFromIncludedTaskfile

* chore: changelog
2023-09-02 21:24:01 +01:00

52 lines
1.2 KiB
Go

package errors
import (
"fmt"
)
// TaskfileNotFoundError is returned when no appropriate Taskfile is found when
// searching the filesystem.
type TaskfileNotFoundError struct {
URI string
Walk bool
}
func (err TaskfileNotFoundError) Error() string {
var walkText string
if err.Walk {
walkText = " (or any of the parent directories)"
}
return fmt.Sprintf(`task: No Taskfile found at "%s"%s`, err.URI, walkText)
}
func (err TaskfileNotFoundError) Code() int {
return CodeTaskfileNotFound
}
// TaskfileAlreadyExistsError is returned on creating a Taskfile if one already
// exists.
type TaskfileAlreadyExistsError struct{}
func (err TaskfileAlreadyExistsError) Error() string {
return "task: A Taskfile already exists"
}
func (err TaskfileAlreadyExistsError) Code() int {
return CodeTaskfileAlreadyExists
}
// TaskfileInvalidError is returned when the Taskfile contains syntax errors or
// cannot be parsed for some reason.
type TaskfileInvalidError struct {
URI string
Err error
}
func (err TaskfileInvalidError) Error() string {
return fmt.Sprintf("task: Failed to parse %s:\n%v", err.URI, err.Err)
}
func (err TaskfileInvalidError) Code() int {
return CodeTaskfileInvalid
}