Update output_spec to convert an error object to string in case it is not already a string. In such a case, the object should be a table with the __tostring metamethod defined, making it convertible to a string.
The assert function does explicitly throw a string, however, the caller can always change the environment such that error will instead throw an error object.
For example:
local olderror = error
error = function(err)
local mt = { __index = {}, __tostring = function(e) return e.message end }
olderror(setmetatable({ message = err }, mt))
end
Update output_spec to convert an error object to string in case it is not already a string. In such a case, the object should be a table with the __tostring metamethod defined, making it convertible to a string.
The assert function does explicitly throw a string, however, the caller can always change the environment such that
error
will instead throw an error object.For example: