8 posts
Posted 27 December 2014 - 01:54 AM
Version: ComputerCraft 1.65
Description:
When running a script to dump the _G variable I am given a "Java exception thrown" message with no other info.
There is no other error in either the computercraft console or the log window.
The file dump.txt is created as expected but isn't filled with anything, when you shutdown the computercraft computer the file is populated with some of the dumped variable.
I have checked that it is not just running out of disk space already!
Expected Results:
A complete dump of the _G variable.
Reproduction Steps:
download this script
http://pastebin.com/0Me2LcRYpastebin get 0Me2LcRY dump
then run it
dump
7083 posts
Location
Tasmania (AU)
Posted 27 December 2014 - 01:56 AM
If you add an a.flush() into the bottom of your loop, you might get a better idea as to where it's sticking.
8 posts
Posted 27 December 2014 - 01:58 AM
If you add an a.flush() into the bottom of your loop, you might get a better idea as to where it's sticking.
No change :/
8543 posts
Posted 27 December 2014 - 02:07 AM
Might be a good idea to tostring everything:
a.write(tostring(key).." "..tostring(value).."\r\n")
7083 posts
Location
Tasmania (AU)
Posted 27 December 2014 - 02:07 AM
So with that in place - running after each line is written - you're still seeing the file contents end at a random point each time you run the script?
8 posts
Posted 27 December 2014 - 02:11 AM
Might be a good idea to tostring everything:
a.write(tostring(key).." "..tostring(value).."\r\n")
Thanks, this fixed it.
Is the fact that there was a Java error still make this a bug or was it just my code?
So with that in place - running after each line is written - you're still seeing the file contents end at a random point each time you run the script?
Yes, it always was ending at the words "printError"
7083 posts
Location
Tasmania (AU)
Posted 27 December 2014 - 02:25 AM
Is the fact that there was a Java error still make this a bug or was it just my code?
Ideally you'd've gotten a more descriptive error. However, it's possible the issue is within LuaJ (the project ComputerCraft makes use of to provide the bulk of the Lua processing in the mod), which Dan tends to dislike tweaking.
Now that you can see what was to be written directly
after "printError", you should be able to see what the problem was. Top-of-my-head guess is that this was the first function to be encountered in the table, in which case a more appropriate error message would go along the lines of "expected: string".
8 posts
Posted 27 December 2014 - 02:43 AM
Is the fact that there was a Java error still make this a bug or was it just my code?
Ideally you'd've gotten a more descriptive error. However, it's possible the issue is within LuaJ (the project ComputerCraft makes use of to provide the bulk of the Lua processing in the mod), which Dan tends to dislike tweaking.
Now that you can see what was to be written directly
after "printError", you should be able to see what the problem was. Top-of-my-head guess is that this was the first function to be encountered in the table, in which case a more appropriate error message would go along the lines of "expected: string".
You were right about it being the first function to appear on the list, now that I think about it, it was probably to do with trying to write a function to a file
a.write(value)
Since there is no way of just triggering a Java error in lua that means that the function is probably being passed into native code and my guess is that somewhere it's type got confused as a string rather than a function.
I'll dig around a little in the fs api and try to find where it's crashing at in there.
EDIT: Hm, I thought the filesystem api was in lua but it appears to be from LuaJ, not really much digging I can do then. :/
Edited on 27 December 2014 - 01:47 AM