scalameta / metals-vscode

Visual Studio Code extension for Metals
https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview
Apache License 2.0
298 stars 75 forks source link

"Internal error" launch config error message #1436

Closed harpocrates closed 9 months ago

harpocrates commented 10 months ago

Describe the bug

When using "Run and Debug" with a launch config, the cryptic "Internal error." dialog shows up in a variety of situations where there's some sort of error.

At least two situations that cause this:

  1. when trying to run non-compiling code, it would be vastly preferable to tell the user their code is not compiling and maybe even focus the "Problems" view so those errors are brought to the front.
  2. when trying to run after specifying a main class that doesn't exist. Here there is a "Main class not found: example.Hello2" error notification bubble, but it would be much better to include that information in the "Internal error" dialog that pops up.

To Reproduce Steps to reproduce the behavior:

  1. Create some small project (I just followed defaults in sbt new scala/scala-seed.g8)
  2. Import the project into metals
  3. Create a launch configuration to call the default entry point (confirm it works)
  4. Edit the project code to make it non-compiling
  5. Try to run again, see the "Internal error." message

Here was my launch config:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "scala",
            "request": "launch",
            "name": "Hello World",
            "mainClass": "example.Hello",
            "buildTarget": "root",
            "args": [],
            "jvmOptions": [],
            "env": {}
        }

    ]
}

Expected behavior

The dialog that pops up should include some information about what went wrong.

Screenshots

Screenshot 2023-11-09 at 12 38 10 PM

Installation:

tgodzik commented 10 months ago

Thanks for reporting! It would be great to improve that behaviour. Last time I checked this was not possible to do sensibly, but I might have missed soemthing.

tgodzik commented 9 months ago

I found a way around that, we can just throw an error with a custom message.

tgodzik commented 9 months ago

Should be fixed in the newest metals snapshots