I have a program that runs a GUI to run multiple programs and if one of the programs encounters an error when the GUI program starts again it prints over the error. is there a way I can save the error in a variable then return the variable to the GUI program, so I can print it out?
[lua][Question] Return an error?
Started by Henness, Feb 09 2013 10:35 AM
3 replies to this topic
#1
Posted 09 February 2013 - 10:35 AM
#2
Posted 09 February 2013 - 11:38 AM
So basically, you use coroutines to run the programs separatly? If a coroutine 'crashes' it won't terminate any other routines. Everytime you do a coroutine.resume(...) it will give you a boolean if it succeeded and then whatever the routine yielded. If the coroutine encounters an error, you will get a false and the error
description. What the parallel api does is, if it
noticed that one coroutine 'crashes' it throws an
error containing the parameters given by the
coroutine.
That means you'll have to write a similar api that will print out the error parameter instead of passing it over to error(parameter).
Hope I didn't mess anything up in my Post.
..Joker
description. What the parallel api does is, if it
noticed that one coroutine 'crashes' it throws an
error containing the parameters given by the
coroutine.
That means you'll have to write a similar api that will print out the error parameter instead of passing it over to error(parameter).
Hope I didn't mess anything up in my Post.
..Joker
#3
Posted 09 February 2013 - 11:43 AM
Try
pcall Catches error's I believe. Not sure if I got the usage correct though
then
ok, err = pcall(functionNameWithNoParentheses, Ar, Gu, Ments)
ok, err = pcall(shell.run, ProgramName, Arguments)
pcall Catches error's I believe. Not sure if I got the usage correct though
then
if ok then
-- didn't error
else
print("Error was:\n" .. err) -- prints the error
end
#4
Posted 09 February 2013 - 11:58 AM
@remiX: The downside of this would be that every coroutine that runs in your parallel api crashes as any of them get's an error, even thought they would still run perfectly. This includes his GUI program...
/> So i don't know if that is really more useful than just let the api stop everything...
(you probably cannot restart the program automatically as there is the chance that it will crash again immediatly...
/> )
(you probably cannot restart the program automatically as there is the chance that it will crash again immediatly...
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











