Improve error message for launch.json parse errors (#1285)

Instead of only showing a generic message that something is wrong with the
`launch.json` this changes the handling to propagate the error message returned
by the JSON decode function.

An example that produces an error:

```
:set ff=unix
:set bomb
```

Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
This commit is contained in:
Kovács Ádám 2024-08-09 10:50:07 +02:00 committed by GitHub
parent 5a3775a964
commit 0e889b8616
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -145,7 +145,11 @@ end
function M._load_json(jsonstr)
local data = assert(M.json_decode(jsonstr), "launch.json must contain a JSON object")
local ok, data = pcall(M.json_decode, jsonstr)
if not ok then
error("Error parsing launch.json: " .. data)
end
assert(type(data) == "table", "launch.json must contain a JSON object")
local inputs = create_inputs(data.inputs or {})
local has_inputs = next(inputs) ~= nil