![]() |
|
Chip status function - Printable Version +- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk) +-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html) +--- Forum: Starfall (https://teamscm.co.uk/forum-7.html) +--- Thread: Chip status function (/thread-726.html) |
Chip status function - LocInt - 13-02-2015 Hey, It would be really nice to get some info of the crashed starfall chip. Like Chip:getStatus() to see if the chip is still alive. Would be also really cool to restart the chip somehow. RE: Chip status function - Person8880 - 13-02-2015 This is working around quota exceeding/chip errors, which is not a good thing. If your chip doesn't error, you never need this.
RE: Chip status function - dalolorn - 14-02-2015 (13-02-2015, 07:02 PM)Person8880 Wrote: This is working around quota exceeding/chip errors, which is not a good thing. Normally, I would agree. But... last time I was on the server, my chips (E2, not Starfall, but... the point is the same) would occasionally get kicked way past the quota for no apparent reason. If I remember correctly, I wasn't the only one experiencing issues - and there was no discernable pattern to the malfunctions to suggest a major error in my code. It's not a very pleasant thing for what is essentially the heart of the ship to break down, leaving you with no way of reacting to your environment - especially when you can't even REACH your chips to fix it. Having the option of SOMEHOW rebooting the system without having to walk up to it with a toolgun would be very useful. RE: Chip status function - Person8880 - 14-02-2015 At the end of the day, that's still a problem with your code, not the quota or anything else. Errors should be fixed, not ignored or avoided. Even if you can't see a reason immediately, there obviously is one or it wouldn't be exceeding. It's better to spend time debugging and fixing than working round it. RE: Chip status function - LocInt - 14-02-2015 (13-02-2015, 07:02 PM)Person8880 Wrote: This is working around quota exceeding/chip errors, which is not a good thing. Well it's just annoying if my chip errors and im not instantly there to fix it. Im planning on backup chip but it would require to get data from the mainchip. I could do that according to the cpuUsage/opsUsage but it would be really cool to be able to reupload the chip using command from another chip. We are human we always make errors. RE: Chip status function - Person8880 - 14-02-2015 Of course you can't be 100% error free. But having something that allows essentially brushing off errors and ignoring them is still not a good thing. People would always just restart their stuff and think "meh I'll fix it someday" rather than actually fixing it and having more stable code. Sometimes it can be annoying for something to error and you're not nearby, yes, but for me that's more motivation to fix it so I don't have to worry about it again. I should note, that for non-quota related errors you can error handle in your code without it crashing. Look at pcall() and xpcall(), also traceback() to help in debugging if you need it. RE: Chip status function - LocInt - 14-02-2015 (14-02-2015, 12:01 PM)Person8880 Wrote: Of course you can't be 100% error free. But having something that allows essentially brushing off errors and ignoring them is still not a good thing. So if I run all my functions using pcall is it like using try catch? It returns error on fail but does not stop running the ship? RE: Chip status function - Person8880 - 14-02-2015 (14-02-2015, 01:15 PM)LocInt Wrote:xpcall is the closest to "try-catch". You can't catch quota errors though.(14-02-2015, 12:01 PM)Person8880 Wrote: Of course you can't be 100% error free. But having something that allows essentially brushing off errors and ignoring them is still not a good thing. Both pcall and xpcall return true, function return values on success or false, error message on failure. xpcall has the added advantage of running a callback when the error occurs so you can get an accurate stack trace with traceback() at that point. Either way, they will not stop the chip if they encounter a non-quota error, yes. That doesn't mean that wrapping the whole thing in pcall is what you should do though (unless you have no shame and want unmaintainable code!) RE: Chip status function - LocInt - 14-02-2015 (14-02-2015, 01:35 PM)Person8880 Wrote:(14-02-2015, 01:15 PM)LocInt Wrote:xpcall is the closest to "try-catch". You can't catch quota errors though.(14-02-2015, 12:01 PM)Person8880 Wrote: Of course you can't be 100% error free. But having something that allows essentially brushing off errors and ignoring them is still not a good thing. Yay now I can run my chip even if it crashes and not fix the error. D
RE: Chip status function - dalolorn - 15-02-2015 (14-02-2015, 10:20 AM)Person8880 Wrote: At the end of the day, that's still a problem with your code, not the quota or anything else. Errors should be fixed, not ignored or avoided. Even if you can't see a reason immediately, there obviously is one or it wouldn't be exceeding. At the end of the day, there is nothing for me to debug. There is no reproduction method - it can run solidly for hours, or it can blow up in my face during the first fifteen minutes, and I still won't have any data to analyze. I could read, double-read and triple-read every line of my code and I probably wouldn't be any closer to figuring out what's wrong - if it's really my code that's doing it. |