diff --git a/README.md b/README.md index 726de3a..44d5309 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ Choosing a store database to use is very simple, you have two ways: + You must known that changing store database runtime is very dangerous, LedisDB will not guarantee the data validation if you do it. + Begin a transaction will block any other write operators before you call `commit` or `rollback`. Don't use long-time transaction. ++ `pcall` and `xpcall` are not supported in lua, you can see the readme in [golua](https://github.com/aarzilli/golua). ## Configuration diff --git a/server/script.go b/server/script.go index c2c8ff2..7ecdfc9 100644 --- a/server/script.go +++ b/server/script.go @@ -159,6 +159,8 @@ func (app *App) openScript() { l.OpenTable() l.OpenPackage() + l.Register("error", luaErrorHandler) + s.l = l s.c = newClient(app) s.c.db = nil @@ -223,6 +225,11 @@ func delMapState(l *lua.State) { delete(mapState, l) } +func luaErrorHandler(l *lua.State) int { + msg := l.ToString(1) + panic(fmt.Errorf(msg)) +} + func luaCall(l *lua.State) int { return luaCallGenericCommand(l) }