Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve quality of error messages #13319

Open
akbyrd opened this issue Jan 30, 2025 · 0 comments
Open

Improve quality of error messages #13319

akbyrd opened this issue Jan 30, 2025 · 0 comments

Comments

@akbyrd
Copy link

akbyrd commented Jan 30, 2025

The error messages from Hugo consist of multiple "frames" all run together as a single line. It's really hard to visually parse.

Example:

ERROR render of "D:/Dev/akbyrd.dev/content/tests/6-test-emoji.md" failed: "D:\Dev\akbyrd.dev\layouts\_default\baseof.html:30:9": execute of template failed: template: _default/single.html:30:9: executing "_default/single.html" at <partial "resource" (dict "Name" "favicon.ico" "Rename" false)>: error calling partial: "D:\Dev\akbyrd.dev\layouts\partials\resource.html:67:24": execute of template failed: template: partials/resource.html:67:24: executing "partials/resource.html" at <$resource.Width>: error calling Width: this method is only available for image resources

In a terminal
Image

In a browser
Image

Honestly, I can't make heads or tails of this. Even trying to figure out where the line breaks should be is confusing. Maybe something like this?

ERROR
render of "D:/Dev/akbyrd.dev/content/tests/6-test-emoji.md" failed:
	"D:\Dev\akbyrd.dev\layouts\_default\baseof.html:30:9":
execute of template failed: template: _default/single.html:30:9:
	executing "_default/single.html" at <partial "resource" (dict "Name" "favicon.ico" "Rename" false)>:
	error calling partial: "D:\Dev\akbyrd.dev\layouts\partials\resource.html:67:24":
execute of template failed: template: partials/resource.html:67:24:
	executing "partials/resource.html" at <$resource.Width>:
	error calling Width: this method is only available for image resources

I think this is closer to ideal

ERROR Method "Width" is only available for image resources
	layouts/partials/resource.html:67:24:  at {{ $width = $resource.Width }}
	layouts/_default/baseof.html:30:9:     at {{ with partial "resource" (dict "Name" "favicon.ico" "Rename" false) -}}
	layouts/_default/single.html           
	content/tests/6-test-emoji.md:         

As it stands today

  • There's no visual line to follow for either locations or error messages
  • The same locations are listed multiple times.
  • Paths are sometimes relative and sometimes absolute
  • There are locations mentioned that don't even exist (single.html is 23 lines long)
  • Column numbers don't quite match reality (issues with whitespace maybe?)
  • Back and forward slashes are mixed, which makes searching with Ctrl+F harder.
  • Impractical to parse with an automated tool (e.g. a vscode problem matcher)

I don't know how much control Hugo has and how much this is dictated by Go templates, but I figure it's worth poking at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant