Skip to content

pcall captures errors differently when debugging #25

@eduardomezencio

Description

@eduardomezencio

(while writing this report, I messed aroung a little to make sure I was not missing anything stupid and ended up finding a solution, so I'll open a PR myself soon. I still decided to open the issue to document it and reference in the PR)

Normally in lua, when you pass a table to the error function and pcall catches this error, the result returned by pcall is the table itself. When debugging with local-lua the result will be a string. This breaks programs that use these tables for complex error handling. I don't know if this is a known side-effect or "feature" of the debugger, but I couldn't find anything on the docs about this.

I observed this debugging with luajit and with lua5.3. Here's a code to reproduce the problem:

local function f()
  error {'a table', x = true}
end

local success, result = pcall(f)
print(success, result)

If you're debugging, result will be a string, otherwise it will be the table it was supposed to be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions