github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/base/lua/print.lua (about)

     1  _tostring = tostring
     2  function tostring(x)
     3      if x == 42 then
     4          error("42!!", 0)
     5      elseif x == 43 then
     6          return 43
     7      end
     8      return _tostring(x)
     9  end
    10  
    11  print(pcall(print, 42))
    12  --> =false	42!!
    13  
    14  print(pcall(print, 43))
    15  --> ~false\t.*: tostring must return a string
    16  
    17  tostring = _tostring