2023-04-15 22:22:25 +02:00
|
|
|
package errors
|
|
|
|
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
// General exit codes
|
|
|
|
const (
|
|
|
|
CodeOk int = iota // Used when the program exits without errors
|
|
|
|
CodeUnknown // Used when no other exit code is appropriate
|
|
|
|
)
|
|
|
|
|
|
|
|
// Taskfile related exit codes
|
|
|
|
const (
|
|
|
|
CodeTaskfileNotFound int = iota + 100
|
|
|
|
CodeTaskfileAlreadyExists
|
2024-05-16 03:24:02 +02:00
|
|
|
CodeTaskfileDecode
|
2023-09-12 23:42:54 +02:00
|
|
|
CodeTaskfileFetchFailed
|
|
|
|
CodeTaskfileNotTrusted
|
|
|
|
CodeTaskfileNotSecure
|
|
|
|
CodeTaskfileCacheNotFound
|
2024-01-12 00:30:02 +02:00
|
|
|
CodeTaskfileVersionCheckError
|
2023-11-17 22:51:10 +02:00
|
|
|
CodeTaskfileNetworkTimeout
|
2024-05-16 03:24:02 +02:00
|
|
|
CodeTaskfileInvalid
|
2023-09-06 02:00:36 +02:00
|
|
|
CodeTaskfileCycle
|
2023-04-15 22:22:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Task related exit codes
|
|
|
|
const (
|
|
|
|
CodeTaskNotFound int = iota + 200
|
|
|
|
CodeTaskRunError
|
|
|
|
CodeTaskInternal
|
|
|
|
CodeTaskNameConflict
|
|
|
|
CodeTaskCalledTooManyTimes
|
2023-06-04 03:33:00 +02:00
|
|
|
CodeTaskCancelled
|
2023-06-30 03:13:41 +02:00
|
|
|
CodeTaskMissingRequiredVars
|
2024-10-18 18:16:57 +02:00
|
|
|
CodeTaskNotAllowedVars
|
2023-04-15 22:22:25 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// TaskError extends the standard error interface with a Code method. This code will
|
|
|
|
// be used as the exit code of the program which allows the user to distinguish
|
|
|
|
// between different types of errors.
|
|
|
|
type TaskError interface {
|
|
|
|
error
|
|
|
|
Code() int
|
|
|
|
}
|
|
|
|
|
|
|
|
// New returns an error that formats as the given text. Each call to New returns
|
|
|
|
// a distinct error value even if the text is identical. This wraps the standard
|
|
|
|
// errors.New function so that we don't need to alias that package.
|
|
|
|
func New(text string) error {
|
|
|
|
return errors.New(text)
|
|
|
|
}
|
2023-09-12 23:42:54 +02:00
|
|
|
|
|
|
|
// Is wraps the standard errors.Is function so that we don't need to alias that package.
|
|
|
|
func Is(err, target error) bool {
|
|
|
|
return errors.Is(err, target)
|
|
|
|
}
|
|
|
|
|
|
|
|
// As wraps the standard errors.As function so that we don't need to alias that package.
|
|
|
|
func As(err error, target any) bool {
|
|
|
|
return errors.As(err, target)
|
|
|
|
}
|
2024-05-16 03:24:02 +02:00
|
|
|
|
|
|
|
// Unwrap wraps the standard errors.Unwrap function so that we don't need to alias that package.
|
|
|
|
func Unwrap(err error) error {
|
|
|
|
return errors.Unwrap(err)
|
|
|
|
}
|