Repository: vscode
Issue: DAP error response handling is confusing and inconsistent
Labels: bug,debug

<!-- ⚠️⚠️ Do Not Delete This! bug_report_template ⚠️⚠️ -->
<!-- Please read our Rules of Conduct: https://opensource.microsoft.com/codeofconduct/ -->
<!-- 🕮 Read our guide about submitting issues: https://github.com/microsoft/vscode/wiki/Submitting-Bugs-and-Suggestions -->
<!-- 🔎 Search existing issues to avoid creating duplicates. -->
<!-- 🧪 Test using the latest Insiders build to see if your issue has already been fixed: https://code.visualstudio.com/insiders/ -->
<!-- 💡 Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. -->
<!-- 🔧 Launch with `code --disable-extensions` to check. -->
Does this issue occur when all extensions are disabled?: Yes/No

<!-- 🪓 If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. -->
<!-- 📣 Issues caused by an extension need to be reported directly to the extension publisher. The 'Help > Report Issue' dialog can assist with this. -->
- VS Code Version: 1.77.3
- OS Version: macOS Ventura 13.3.1 

# Steps to reproduce
1. Respond e.g. to the "initialize" DAP requests with the various combinations explained below.

# Various combinations in the error response

Handling of debug adapter protocol error responses is confusing:
* `showUser` (from DAP) and `showErrors` (passed to `send`) are ignored when a `url` is provided - it will always show a dialog: 
* if `showUsers` is `false`, `showErrors` is ignored - it will never show a message (this may be fine, but then `showErrors` could probably be named better)
* if `showUser` is `true`
  * ...`showErrors` confusingly controls whether to show them in a dialog (`showErrors= false`) or in a notification (`showErrors=true`)
  * ... and `showErrors` is `false`, and no `error.format` is send from DAP, it will still show a dialog, but the dialog will be empty, looking broken.

This is the logic I am referring to:
https://github.com/microsoft/vscode/blob/c29e4b0fdb6b63c23be7055feb5a188784a86691/src/vs/workbench/contrib/debug/browser/rawDebugSession.ts#L760-L785


DAP unfortunately does not specify exactly what should happen if showUser is false but a URL is provided: https://github.com/microsoft/debug-adapter-protocol/issues/387

It also does not seem to have a way to express severity so that one could decide whether a dialog or a notification is more appropriate. In the absence of that, maybe this should be decided based on criticality of the request?

I think it would make sense that:
* failing a critical request always causes an error dialog 
  * if `showUser=true`, it should have the text from the DAP response
  * if `showUser=false`, it should be a generic failure message generated on the client
* failing a non-critical request
  * ...with `showUser=true` should show a notification - if a `url` is provided, it could be a prompt notification with actions
  * ...with `showUser=false` should not show anything to the user

In my mind, `"initialize"` is a critical requests. I wonder why VSCode chose to set `showErrors=false` for `"initialize"` requests (and `true` for almost everything else) - maybe it is because a failure to initialize then causes a "disconnect" request, which already shows an error? 

@weinand @roblourens and @isidorn Seems to have worked on this function and may have additional background as to the intentions here?

I would be happy to contribute here, but we probably need to get on the same page regarding the desired behavior first.