Describe the bug
On error the data.error
key doesn’t exist, but is given as an example in the documentation. The error message can be found in data.message
.
To Reproduce
Use the websocket callback from the documentation (slightly modified to run without a logger):
local function websocket_callback(self, conn, data)
if data.event == websocket.EVENT_DISCONNECTED then
print("Disconnected: " .. tostring(conn))
self.connection = nil
elseif data.event == websocket.EVENT_CONNECTED then
self.connection = conn
print("Connected: " .. tostring(conn))
elseif data.event == websocket.EVENT_ERROR then
print("Error: '" .. data.error .. "'")
elseif data.event == websocket.EVENT_MESSAGE then
print("Receiving: '" .. tostring(data.message) .. "'")
end
end
and call a non-existing WS url so an error is generated.
Expected behaviour
Either the documentation adjusted or correct keys populated.
Defold version (REQUIRED):
- Defold version: 1.2.174
- Websocket extension version: 1.4.0
Platforms (REQUIRED):
- Any
Minimal repro case project:
Websocket.zip (2.9 KB)
Logs:
ERROR:SCRIPT: /main/network.script:9: attempt to concatenate field 'error' (a nil value)
stack traceback:
/main/network.script:9: in function </main/network.script:1>
Workaround:
Use data.message
instead of data.error
.