Skip to content

Commit 5105462

Browse files
committed
Update return handling
Signed-off-by: Dusan Borovcanin <[email protected]>
1 parent 78f9a17 commit 5105462

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bit/api.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ const (
2323
func Bitwise(kind op) lua.LGFunction {
2424
return func(l *lua.LState) int {
2525
if kind > rs {
26-
l.Push(lua.LString("invalid type of operation"))
27-
return 1
26+
l.RaiseError("unsupported operation type")
27+
return 0
2828
}
2929
val1, val2, err := prepareParams(l)
3030
if err != nil {
31+
l.Push(lua.LNil)
3132
l.Push(lua.LString(err.Error()))
32-
return 1
33+
return 2
3334
}
3435
var ret uint32
3536
switch kind {
@@ -53,6 +54,7 @@ func Bitwise(kind op) lua.LGFunction {
5354
func Not(l *lua.LState) int {
5455
val, err := intToU32(l.CheckInt(1))
5556
if err != nil {
57+
l.Push(lua.LNil)
5658
l.Push(lua.LString(err.Error()))
5759
return 1
5860
}

0 commit comments

Comments
 (0)