Some (but not all) functions give basic information on failure, for example: which argument is not as expected (if there are multiple arguments) and what would have been expected instead. This should be expanded as best practise for all functions.
A good practise seems to consist of following elemets:
Other error messages do not talk about wrong type, but wrong value.
Example for best practise yet: "setBackgroundColor: bad argument #%d value (red value needs to be between 0-255, got %d)"
Suggestion along lines of above: "(Optional) Argument #%d (red value) has unexpected value! Expected value needs to be between 0-255, got %d"
Actually the wrong value cases (colloquially, or at least by me, called run-time errors because the supplied arguments are of the right type but not the right values to produce valid results) are already starting to be redone and moving away from the example quoted in the last post. They:
setBackgroundColor: in the example above, because, IIRC according to Vadim the user knows what the function is so there is no need to repeat it).lua_error(L) to abort execution) and may wrapped in additional text for presentation purposes.With regard to the initial issue report I would note that the use of the phrase as XXXX expected, got YYYY! indicates a required argument in those messages about the wrong type - I've just counted something of the order of 180 examples of that in the TLuaInterpreter.cpp file... and for optional arguments the text will be as XXXX is optional, got YYYY! and I've spotted 20 of those right now. :grinning:
Here follows an inventory of TLuaInterpreter's public functions
(there are other files establishing public functions as well, but this seems to be the largest flock)
Source: TLuaInterpreter::initLuaGlobals
Position in following groups indicate whether error messages are (somewhat) standardized:
✅ These functions have been fixed now
(to be filled from below)
âš¡ Error messages to be standardized indeed
Source-code needs to be edited, messages need to be improved. Afterwards, move to above "fixed" section and/or set check-mark
✅ These functions were already standardizing messages alright
✅ Internal functions - unknown to users
✅ Functions without arguments - fine already! 😄
Verification is not yet complete, but already found 65 functions needing work. âš¡
My last message above is continuously updated with the latest status for each.
To avoid uncontrolled growth of different error message styles again, creation of said message should be centralised in a helping function, which only receives details as listed above, and returns the full string. Therefore, future adjustments to sentence structure can be delivered _once and for all_ easily.
Not sure if this refactorization can be done prior or is out of scope here.
Danger if not done lies in sandardized error messages today, tomorrow having wild growth again.
Verification done. After looking at these 400 functions published from TLuaInterpreter for a few more hours, we have a total of 80 functions to fix. You can find the whole list behind the spoiler tags in my comment above. Any volunteers?

There were also a few slips and careless mistakes which could have been avoided with my suggested refactoring in the OP.
E.g. function X reporting itself as function Y instead (copy/paste error probably, but actually unnecessary duplication of data)
While there is still ongoing work internally to streamline and standardize text creation, this issue is mostly done.
The players only see the "wrong argument type" style error message in setPopup() and no other function anymore.
As explained in https://github.com/Mudlet/Mudlet/pull/4599#issuecomment-756775208 there are differences in code and wiki documentation still
I will mark this as done. The only function remaining (setPopup) is discussed in a seperate issue #4641 still.
Meanwhile we established the requested helper functions and gave meaningful type errors and value errors to all c++ functions.
Checked Lua functions, too. Not all of them check all their arguments already, but if they do, they give informative error messages.
Most helpful comment
I will mark this as done. The only function remaining (setPopup) is discussed in a seperate issue #4641 still.
Meanwhile we established the requested helper functions and gave meaningful type errors and value errors to all c++ functions.
Checked Lua functions, too. Not all of them check all their arguments already, but if they do, they give informative error messages.