As lhf mentions, it is very easy to redefine any function in Lua, but I think this may not be what you need. The issue is that after you do
local origAssert = assert
assert = function(message)
do something (possibly using origAssert)
end
then every function call that uses assert will use your new assert function, which is probably not what you want. Instead, you can call your function in "protected" mode: this will trap the assertion as an error message, and you can then decide what to do. For example,
ok, ret1, ret2 = pcall(yourFunction, arg1)
if not ok then
do something, possibly print ret1 (the error message)
end
Same thing if you are requiring a module that does some initialization:
ok, module = pcall(require, yourModuleName)
if not ok then
print("ERROR:", module) -- if not ok then module is err message
end