Jump to content




question - how to detect, if a program crash


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

#1 Goof

  • Members
  • 751 posts

Posted 31 December 2012 - 10:58 AM

Hello.

does anyone know how to make a detector, that detects if my program is beginning to crash. (
Like in the firewolf crash system)

thanks in advance :)

#2 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 31 December 2012 - 11:04 AM

This sounds like a job for pcall.

local function stupidFunction()
  callingANilValue()
end

local ok, err = pcall(stupidFunction)
if not ok then
  print(err)
end

pcall stands for "protected call", and it allows you to call functions and catch errors if any. In this example, "ok" is whether or not the function call was successful, and if ok is false, "err" is the error message.

#3 Goof

  • Members
  • 751 posts

Posted 31 December 2012 - 11:11 AM

Thanks for that. I didnt know that it could be printed, before the error is there. But the pcall worked fine... thank you !

:D :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users