“Essayez sauf Lua” Réponses codées

Essayez sauf Lua

require "try-catch"

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

   catch {
      function(error)
         print('caught error: ' .. error)
      end
   }
}
Naughty Nightingale

Erreur de catch LUA

-- The pcall (f, arg1, ...) function calls the requested function in
-- protected mode. If some error occurs in function f, it does not throw
-- an error. It just returns the status of error. A simple example using
-- pcall is shown below.

Live Demo
function myfunction ()
   n = n/nil
end

if pcall(myfunction) then
   print("Success")
else
	print("Failure")
end
Ugliest Unicorn

Réponses similaires à “Essayez sauf Lua”

Questions similaires à “Essayez sauf Lua”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code