Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error stack/tracebacks? #58

Open
tisba opened this issue Aug 6, 2017 · 1 comment
Open

Error stack/tracebacks? #58

tisba opened this issue Aug 6, 2017 · 1 comment

Comments

@tisba
Copy link

tisba commented Aug 6, 2017

Hi there!

little disclaimer first: I'm not terribly familiar with go. I'm trying to take a look around how to use lua with go. I've opened a similar issue with Shopify/go-lua#87 because I had the same problem with (missing) tracebacks.

I'm struggling a bit on how to get proper tracebacks for errors.

Giving this hello.lua file containing:

print("Hello World")

function foo()
  print("Hello, I'm foo!")
  bar()
end

foo()

…run with lua hello.lua gives me:

Hello World
Hello, I'm foo!
lua: hello.lua:5: attempt to call global 'bar' (a nil value)
stack traceback:
	hello.lua:5: in function 'foo'
	hello.lua:8: in main chunk
	[C]: in ?

With golua used in file.go:

package main

import "../lua"
import "fmt"

func main() {
	L := lua.NewState()
	defer L.Close()
	L.OpenLibs()

	err := L.DoFile("hello.lua")

	fmt.Printf("%v\n", err)
}

…run with go run file.go gives me:

Hello World
Hello, I'm foo!
hello.lua:5: attempt to call global 'bar' (a nil value)

How can I get a comparable traceback with golua? Something that can be presented to a user. Are there more examples somewhere?

@aarzilli
Copy link
Owner

aarzilli commented Aug 7, 2017

I don't think it's collected anywhere, you'd have to change golua.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants