Returning of errors from Lua functions is often done by returning nil + error message (nil,string):
---@return table
---@overload fun(): nil, string
local function doSomething()
but this syntax can get complex when function takes parameters, or has other overloads. An old solution from LDoc was to use a @error annotation - I propose to add something similar to LuaLS.