premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

It would be nice to have better error identification.

Open Codinablack opened this issue 1 year ago • 4 comments

Right now when you get a simple error such as "String expected got table" you have to have either been retrying your script after each line edit to know where to look, or have a good feeling because you have been testing many things.

What would be nice is if the error told you the line of which the error occurred on. This could help more people figure out their own problems before having to seek help here.

Codinablack avatar Mar 26 '24 20:03 Codinablack

Most of those errors come from Lua directly.

Jarod42 avatar Mar 28 '24 18:03 Jarod42

It has been my experience with everything lua I have ever interacted with (except for this obviously), always identifies the line as well as the value or function that contained a value other than expected. So instead of getting "String expected got table" it would say something like :

"error on line 172 with "coolvar" string expected got nil value file </user/location/directory/filename.lua> line 127 callstack "coolfunc()" "

Something to that degree. It doesn't have to be super detailed with an entire call stack (but that would be of most use), but at least the line where the error occurs and the variable name, that would be very beneficial.

That would be really awesome to have something like that

Codinablack avatar Apr 10 '24 04:04 Codinablack

As a workaround I just ended up modifying _premake_main.lua to wrap the entry point in a xpcall to get a full stack trace

  local function main()
    p.callArray(m.elements)
  end

  function _premake_main()
    local success, result = xpcall(main, debug.traceback)
    if not success then
      print(result)
      return 1
    end
    return 0
  end

fsfod avatar Apr 16 '24 06:04 fsfod

This wrapper should be the default behaviour.

The standard error message just gives a line number in the middle of a comment block. It's utterly useless.

crazydef avatar May 21 '25 09:05 crazydef