Re: [code] [textadept] Crashing when setting the color for line numbers

From: Chris Emerson <c-ta.att.mail.nosreme.org>
Date: Wed, 9 Sep 2015 09:19:04 +0100

Hi Attila,

(Resending with the right address, in case the previous one gets through)

On Wed, 9 Sep 2015 09:29:32 +0200, Attila Nemeth <at.nemeth.att.gmail.com> wrote:
> I am using the GUI version, and the crash was happening with the GUI
> version. I'm suspecting that the cause of the crash is me doing something
> foolish in lua since I'm very new to it, or the way I'm doing something is
> wrong.

I do two things for debugging Lua scripts:

1. Logging. In my init.lua, I have something like:

local log_file
function _G.my_log(msg)
    if log_file == nil then
        log_file = io.open("ta_debug.txt", "w") -- use full path if needed
    end
    log_file:write(tostring(msg)..'\n')
    log_file:flush()
end

Then I can sprinkle my_log("Entered foo(), x="..tostring(x)) around.

2. Run any code you're suspicious of under (x)pcall, eg:

local res, msg = xpcall(function()
--[[ code you want to run here
...
]]
end, function(msg)
    return debug.traceback(msg) -- Add traceback to any error raised
end) -- end of xpcall call
if not res then
    -- Log the error, eg into a file
    f = io.open("ta_error.txt", "w")
    f:write(msg)
    f:close()
end

I actually wrap my whole init.lua in the above.

If you're running in the Windows GUI version, you might want to use a full
path to log/error files, eg "c:\\temp\\ta_debug.txt" to be sure they go
somewhere useful.

Hope this helps,

Chris

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Wed 09 Sep 2015 - 04:19:04 EDT

This archive was generated by hypermail 2.2.0 : Wed 09 Sep 2015 - 06:44:20 EDT