mirror of
https://github.com/go-task/task.git
synced 2025-11-23 22:24:45 +02:00
feat: prefer remote taskfiles over cached ones (#1345)
* feat: prefer remote taskfiles over cached ones * feat: implemented cache on network timeout * feat: --download always downloads, but never executes tasks * feat: --timeout flag * fix: bug with timeout error handling * chore: changelog
This commit is contained in:
@@ -3,6 +3,7 @@ package errors
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TaskfileNotFoundError is returned when no appropriate Taskfile is found when
|
||||
@@ -137,3 +138,26 @@ func (err *TaskfileVersionNotDefined) Error() string {
|
||||
func (err *TaskfileVersionNotDefined) Code() int {
|
||||
return CodeTaskfileVersionNotDefined
|
||||
}
|
||||
|
||||
// TaskfileNetworkTimeout is returned when the user attempts to use a remote
|
||||
// Taskfile but a network connection could not be established within the timeout.
|
||||
type TaskfileNetworkTimeout struct {
|
||||
URI string
|
||||
Timeout time.Duration
|
||||
CheckedCache bool
|
||||
}
|
||||
|
||||
func (err *TaskfileNetworkTimeout) Error() string {
|
||||
var cacheText string
|
||||
if err.CheckedCache {
|
||||
cacheText = " and no offline copy was found in the cache"
|
||||
}
|
||||
return fmt.Sprintf(
|
||||
`task: Network connection timed out after %s while attempting to download Taskfile %q%s`,
|
||||
err.Timeout, err.URI, cacheText,
|
||||
)
|
||||
}
|
||||
|
||||
func (err *TaskfileNetworkTimeout) Code() int {
|
||||
return CodeTaskfileNetworkTimeout
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user