mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 17:28:52 -04:00
follow fail pattern for addUser: throw on bad arg, nil on bad result
closes #2156
This commit is contained in:
parent
e91b8c0971
commit
f11d384b51
@ -77,8 +77,10 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
|
|||||||
})
|
})
|
||||||
lua.setField(-2, "users")
|
lua.setField(-2, "users")
|
||||||
|
|
||||||
lua.pushScalaFunction(lua => try {
|
lua.pushScalaFunction(lua => {
|
||||||
machine.addUser(lua.checkString(1))
|
val user = lua.checkString(1)
|
||||||
|
try {
|
||||||
|
machine.addUser(user)
|
||||||
lua.pushBoolean(true)
|
lua.pushBoolean(true)
|
||||||
1
|
1
|
||||||
} catch {
|
} catch {
|
||||||
@ -86,6 +88,7 @@ class ComputerAPI(owner: NativeLuaArchitecture) extends NativeLuaAPI(owner) {
|
|||||||
lua.pushNil()
|
lua.pushNil()
|
||||||
lua.pushString(Option(e.getMessage).getOrElse(e.toString))
|
lua.pushString(Option(e.getMessage).getOrElse(e.toString))
|
||||||
2
|
2
|
||||||
|
}
|
||||||
})
|
})
|
||||||
lua.setField(-2, "addUser")
|
lua.setField(-2, "addUser")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user