Answers for "pcall lua"

2

try except lua

require "try-catch"

try {
   function()
      error('oops')
   end,

   catch {
      function(error)
         print('caught error: ' .. error)
      end
   }
}
Posted by: Guest on June-23-2020
0

pcall lua

if pcall(foo) then
      -- no errors while running `foo'
      ...
    else
      -- `foo' raised an error: take appropriate actions
      ...
    end
Posted by: Guest on October-19-2021

Browse Popular Code Answers by Language