mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
fix(diagnostic): error on invalid severity value (#15965)
Users can pass string values for severities that match with the enum names (e.g. "Warn" or "Info") which are converted to the corresponding numerical value in `to_severity`. Invalid strings were simply left as-is, which caused confusing errors later on. Instead, report an invalid severity string right up front to make the problem clear.
This commit is contained in:
parent
3f09732195
commit
d5dd0aa1e6
@ -27,7 +27,10 @@ local global_diagnostic_options = {
|
||||
|
||||
---@private
|
||||
local function to_severity(severity)
|
||||
return type(severity) == 'string' and M.severity[string.upper(severity)] or severity
|
||||
if type(severity) == 'string' then
|
||||
return assert(M.severity[string.upper(severity)], string.format("Invalid severity: %s", severity))
|
||||
end
|
||||
return severity
|
||||
end
|
||||
|
||||
---@private
|
||||
|
Loading…
Reference in New Issue
Block a user