mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
errors: Misc improvements
* Redo the server error template * Always add the content file context if relevant * Remove some now superflous error string matching * Move the server error template to _server/error.html * Add file context (with position) to codeblock render blocks * Improve JS build errors Fixes #9892 Fixes #9891 Fixes #9893
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
||||
jww "github.com/spf13/jwalterweatherman"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/common/herrors"
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
"github.com/gohugoio/hugo/hugolib"
|
||||
)
|
||||
@@ -116,7 +115,7 @@ func TestTransformPostCSS(t *testing.T) {
|
||||
|
||||
b.AssertFileContent("public/index.html", `
|
||||
Styles RelPermalink: /css/styles.css
|
||||
Styles Content: Len: 770875|
|
||||
Styles Content: Len: 770917|
|
||||
`)
|
||||
|
||||
}
|
||||
@@ -138,13 +137,6 @@ func TestTransformPostCSSError(t *testing.T) {
|
||||
}).BuildE()
|
||||
|
||||
s.AssertIsFileError(err)
|
||||
fe := herrors.UnwrapFileError(err)
|
||||
pos := fe.Position()
|
||||
c.Assert(strings.TrimPrefix(pos.Filename, s.H.WorkingDir), qt.Equals, filepath.FromSlash("/assets/css/components/a.css"))
|
||||
c.Assert(pos.LineNumber, qt.Equals, 4)
|
||||
errctx := fe.ErrorContext()
|
||||
c.Assert(errctx, qt.IsNotNil)
|
||||
c.Assert(errctx.Lines, qt.DeepEquals, []string{"/* Another comment. */", "class-in-a {", "\t@apply foo;", "}", ""})
|
||||
c.Assert(errctx.ChromaLexer, qt.Equals, "css")
|
||||
c.Assert(err.Error(), qt.Contains, "a.css:4:2")
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user