“Попробуйте, кроме Луа” Ответ

Попробуйте, кроме Луа

require "try-catch"

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

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

Lua Catch Error

-- 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

Ответы похожие на “Попробуйте, кроме Луа”

Вопросы похожие на “Попробуйте, кроме Луа”

Смотреть популярные ответы по языку

Смотреть другие языки программирования