Jump to content




checking for errors


  • You cannot reply to this topic
2 replies to this topic

#1 ZagKalidor

  • Members
  • 111 posts

Posted 06 April 2017 - 01:02 PM

Hey guys,

i know there is a possibility to check for errors, throwed by the terminal inside some program but i could not find propper solution. Searching with the keyword "error" gives a lot of documents, that can't be read completely. So i try to ask it here. Please appologise if it is a FAQ.

How do i check for errors and continue in a specific way, like

if there is error a then do this...
if there is error b then do that...

Thanks and greetings to all
Zag

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 06 April 2017 - 03:15 PM

You want pcall.

local ok, result = pcall(someFunc)

if ok then
  -- No error, "result" has the return value of someFunc().

else
  -- Error, "result" is a string with the message.

  if result == "some error" then
    ...

  elseif result == "some other error" then
    ...

  end
end


#3 ZagKalidor

  • Members
  • 111 posts

Posted 06 April 2017 - 06:01 PM

Thanks Bomb, have to see how to implement this, thx a lot...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users