Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-02 17:07:52 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-06 20:43:22 +0300
commitf2946da9e806c2bafbdd26707fe339db79bd980b (patch)
treeb5609317a861ea5f399e094e1b9287ca71dc22d1 /modules/collect.go
parent6eea32bd6bc8e7a7dd07a8cb6a8343ae2c74aba0 (diff)
Improve error messages, esp. when the server is running
* Add file context to minifier errors when publishing * Misc fixes (see issues) * Allow custom server error template in layouts/server/error.html To get to this, this commit also cleans up and simplifies the code surrounding errors and files. This also removes the usage of `github.com/pkg/errors`, mostly because of https://github.com/pkg/errors/issues/223 -- but also because most of this is now built-in to Go. Fixes #9852 Fixes #9857 Fixes #9863
Diffstat (limited to 'modules/collect.go')
-rw-r--r--modules/collect.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/modules/collect.go b/modules/collect.go
index e012d4696..ff83f9ecc 100644
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -36,7 +36,7 @@ import (
"github.com/rogpeppe/go-internal/module"
- "github.com/pkg/errors"
+ "errors"
"github.com/gohugoio/hugo/config"
"github.com/spf13/afero"
@@ -48,7 +48,7 @@ const vendorModulesFilename = "modules.txt"
// IsNotExist returns whether an error means that a module could not be found.
func IsNotExist(err error) bool {
- return errors.Cause(err) == ErrNotExist
+ return errors.Is(err, os.ErrNotExist)
}
// CreateProjectModule creates modules from the given config.
@@ -289,7 +289,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool
return nil, nil
}
if found, _ := afero.Exists(c.fs, moduleDir); !found {
- c.err = c.wrapModuleNotFound(errors.Errorf(`module %q not found; either add it as a Hugo Module or store it in %q.`, modulePath, c.ccfg.ThemesDir))
+ c.err = c.wrapModuleNotFound(fmt.Errorf(`module %q not found; either add it as a Hugo Module or store it in %q.`, modulePath, c.ccfg.ThemesDir))
return nil, nil
}
}
@@ -297,7 +297,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool
}
if found, _ := afero.Exists(c.fs, moduleDir); !found {
- c.err = c.wrapModuleNotFound(errors.Errorf("%q not found", moduleDir))
+ c.err = c.wrapModuleNotFound(fmt.Errorf("%q not found", moduleDir))
return nil, nil
}
@@ -557,7 +557,7 @@ func (c *collector) collectModulesTXT(owner Module) error {
line = strings.TrimSpace(line)
parts := strings.Fields(line)
if len(parts) != 2 {
- return errors.Errorf("invalid modules list: %q", filename)
+ return fmt.Errorf("invalid modules list: %q", filename)
}
path := parts[0]
@@ -662,7 +662,7 @@ func (c *collector) normalizeMounts(owner *moduleAdapter, mounts []Mount) ([]Mou
targetBase = mnt.Target[0:idxPathSep]
}
if !files.IsComponentFolder(targetBase) {
- return nil, errors.Errorf("%s: mount target must be one of: %v", errMsg, files.ComponentFolders)
+ return nil, fmt.Errorf("%s: mount target must be one of: %v", errMsg, files.ComponentFolders)
}
out = append(out, mnt)
@@ -672,7 +672,7 @@ func (c *collector) normalizeMounts(owner *moduleAdapter, mounts []Mount) ([]Mou
}
func (c *collector) wrapModuleNotFound(err error) error {
- err = errors.Wrap(ErrNotExist, err.Error())
+ err = fmt.Errorf(err.Error()+": %w", ErrNotExist)
if c.GoModulesFilename == "" {
return err
}
@@ -681,9 +681,9 @@ func (c *collector) wrapModuleNotFound(err error) error {
switch c.goBinaryStatus {
case goBinaryStatusNotFound:
- return errors.Wrap(err, baseMsg+" you need to install Go to use it. See https://golang.org/dl/.")
+ return fmt.Errorf(baseMsg+" you need to install Go to use it. See https://golang.org/dl/ : %q", err)
case goBinaryStatusTooOld:
- return errors.Wrap(err, baseMsg+" you need to a newer version of Go to use it. See https://golang.org/dl/.")
+ return fmt.Errorf(baseMsg+" you need to a newer version of Go to use it. See https://golang.org/dl/ : %w", err)
}
return err