Skip to content

Commit

Permalink
Merge pull request #221 from depot/feat/simplify-missing-file-error
Browse files Browse the repository at this point in the history
feat: clarify missing file error message
  • Loading branch information
goller authored Nov 14, 2023
2 parents 2ef3252 + 2972eb9 commit 7aef753
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/buildx/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -1093,6 +1094,13 @@ func rewriteFriendlyErrors(err error) error {
if strings.Contains(err.Error(), "header key \"exclude-patterns\" contains value with non-printable ASCII characters") {
return errors.New(err.Error() + ". Please check your .dockerignore file for invalid characters.")
}
if strings.Contains(err.Error(), "failed to calculate checksum of ref") {
pattern := `failed to solve: failed to compute cache key: failed to calculate checksum of ref [^:]+::[^:]+:`
re := regexp.MustCompile(pattern)

simplified := re.ReplaceAllString(err.Error(), "")
return errors.New(simplified + ". Please check if the files exist in the context.")
}
return err
}

Expand Down

0 comments on commit 7aef753

Please sign in to comment.