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

Prettier error display, like pretty-typescript-error extension #3644

Open
WWology opened this issue Jan 1, 2025 · 5 comments
Open

Prettier error display, like pretty-typescript-error extension #3644

WWology opened this issue Jan 1, 2025 · 5 comments
Milestone

Comments

@WWology
Copy link

WWology commented Jan 1, 2025

Is your feature request related to a problem? Please describe.
Error messages on complex types and functions can be messy and tricky to read and understand
For example

cannot use signup.GardenerCommandHandler (value of type func(b *"clockey/bot".Bot) handler.MessageCommandHandler) as handler.MessageCommandHandler value in argument to h.MessageCommand

Describe the solution you'd like
It'll be nice if we can have error display like in the popular vscode extension, Pretty Typescript Error
https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors

So instead of the error above
We can instead display

cannot use

signup.GardenerCommandHandler

(value of type func(b *"clockey/bot".Bot) handler.MessageCommandHandler) as handler.MessageCommandHandler value in argument to h.MessageCommand

Something to this effect

@gopherbot gopherbot added this to the Untriaged milestone Jan 1, 2025
@WWology
Copy link
Author

WWology commented Jan 1, 2025

A screenshot from the vscode extension that i talked about
image

@firelizzard18
Copy link
Contributor

firelizzard18 commented Jan 1, 2025

In what context are you seeing this error? Is it a diagnostic (squiggly red line) in the editor or something else? IIRC diagnostics are provided by the language server, gopls. Rich diagnostic messages would probably be most easily provided by gopls because (I think) it has access to the underlying error before it's stringified. But I'm not familiar with the details of the language server protocol and I don't know if it's possible for gopls to provide rich messages through the standard protocol, though I'd guess it is.

@WWology
Copy link
Author

WWology commented Jan 2, 2025

Hi,

The errors are coming from the squigly red line of the editor yes, Showing up in the problem tab of vscode, i'm assuming it's coming from the LSP when it detects compiler error.

I'm assuming gopls would be able to do some sort of check if it's running in an editor that's capable of ouputting rich diagnostic messages and then returning that, and returning the standard error message if it's not running in an editor capable of it?

@hyangah
Copy link
Contributor

hyangah commented Jan 6, 2025

Upstream issue: microsoft/vscode#54272

The pretty ts error extension seems to implement a hover message provider that digests diagnostics messages and formats it. https://github.com/yoavbls/pretty-ts-errors/blob/main/src/extension.ts

Btw, if the error message came from the compiler, I don't know how perfectly gopls can reformat compiler's message.

@firelizzard18
Copy link
Contributor

Btw, if the error message came from the compiler, I don't know how perfectly gopls can reformat compiler's message.

I just meant that it would be less difficult to implement with gopls vs with the extension since gopls will at least have some error type vs the extension just has raw text. But I agree, reformatting the compiler's message would be challenging if the errors aren't structured. IIRC they have some structure but not enough to make it easy.

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

No branches or pull requests

4 participants