2427 posts
Location
UK
Posted 31 March 2018 - 08:58 PM
Edit: Latest problem:
http://www.computerc...post__p__276561Original post:
I want to be able to blaim the callback for errors when they happen, unfortunatly it's not as simple as error(msg, 2).
Currently only the Checkpoint file gets blamed.
I've even got
stack tracing curtisy of Apemanzilla.
Stranger still, it should be erroring but seems to not be.
View code online:
https://github.com/C...0343c9c7a8b8e0bDownload latest code in game with: (note this is not the same as the above link)
pastebin run W5ZkVYSi CC-Hive Checkpoint
Run test.lua
Edited on 01 April 2018 - 02:18 PM
355 posts
Location
Germany
Posted 31 March 2018 - 09:32 PM
I don't have a client at hand to run your code, and your question really leaves a lot of room for interpretation. Like what's the current behavior and desired behavior of your code. But I will formulate an equally vague response to that:
Note: I also have no idea what tracing curtisy of apemanzilla is.
If you run a callback passed by "user code" in your framework, you don't have to mess with error handling, as errors would point towards the definition of the callback, which happened in the "user code".
Your framework would be part of the call stack, but that is fine, but that doesn't "blame" it. It would be possible for you to catch it using pcall, but other than rethrowing you really can't do much in most scenarios, as you don't know what's about to happen in the callback. That's why it's a callback in the first place.
If you have pcall in your callstack already (for other code) before executing the callback function, then of course you need to make sure the original error bubbles up the chain without losing track of the original error message.
463 posts
Location
Star Wars
Posted 31 March 2018 - 09:49 PM
I am not sure, what you want to do
local oldCallback = callback
local newCallback = function()
local ok, err = pcall(callback)
if not ok then
error(err);
end
end
would manage errors, thrown by the callback.
local callbacks = {}
function assignError(msg, id)
callbacks[id].error = msg
sleep(0)
end
function makeCallback(callback)
local id = #callbacks + 1
callbacks[id] = { callback = function()
local co = coroutine.create(callback)
while true do
if callbacks[id].error then
error(callbacks[id].error, 1)
end
-- handle coroutine execution...
end
end, error = nil}
end
would assign an error to a preassigned function. Note: this is just a concept, i haven't tested anything.
Hopefully i could help.
Greetings
Sewbacca
2427 posts
Location
UK
Posted 31 March 2018 - 10:18 PM
I am not sure, what you want to do
local oldCallback = callback
local newCallback = function()
local ok, err = pcall(callback)
if not ok then
error(err);
end
end
would manage errors, thrown by the callback.
I've kinda
done that and it hasn't worked.
2427 posts
Location
UK
Posted 31 March 2018 - 10:40 PM
SquidDev helped me on gitter resulting in this version of the code:
https://github.com/CC-Hive/Checkpoint/tree/0efe3191cfda089c8d41cead0cad587ca2f66977It works now, needs some cleanup but I should be able to manage.
2427 posts
Location
UK
Posted 01 April 2018 - 12:30 AM
Ok. I thought I had this solved but I've got more issues, the intentional error is not working, infact the second part of the test file doesn't even run.
I even tried using the trace functionality from
MBS.
https://github.com/C...39580f6bb9fc80bI think the .checkpoint file is not being made for some reason.
Edited on 31 March 2018 - 10:34 PM
2427 posts
Location
UK
Posted 01 April 2018 - 02:32 PM
Is half a day long enough before a bumb?
2427 posts
Location
UK
Posted 01 April 2018 - 04:17 PM
SquidDev to the rescue again:
https://github.com/CC-Hive/Checkpoint/tree/9c3ae2df6e48a2545c82eecf3c22676f4cc7cd44Error or not, the API deleted the .checkpoint file which it was not suposed to do.