Skip to content

Commit

Permalink
fix(callback): bad argument to unpack when callback throws error
Browse files Browse the repository at this point in the history
Throwing an error responds with false rather than a string.
  • Loading branch information
thelindat committed Oct 19, 2022
1 parent 6f0bf6a commit 2bb0d68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion imports/callback/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ local function triggerServerCallback(_, event, delay, cb, ...)
return promise:resolve(response and { msgpack.unpack(response) } or {})
end

return cb and cb(msgpack.unpack(response))
return cb and cb(response and msgpack.unpack(response))
end

if promise then
Expand Down
6 changes: 4 additions & 2 deletions imports/callback/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local function triggerClientCallback(_, event, playerId, cb, ...)
return promise:resolve(response and { msgpack.unpack(response) } or {})
end

return cb and cb(msgpack.unpack(response))
return cb and cb(response and msgpack.unpack(response))
end

if promise then
Expand Down Expand Up @@ -74,4 +74,6 @@ function lib.callback.register(name, cb)
end)
end

return lib.callback
return lib.callback


0 comments on commit 2bb0d68

Please sign in to comment.