forked from mirror/ledisdb
replace lua error
error may cause c stack overflow https://github.com/aarzilli/golua/issues/24
This commit is contained in:
parent
d9a8da770d
commit
9628817ca4
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue