event.isError

Type Boolean
Event networkRequest
Revision 2017.3060
Keywords networkRequest, isError

Overview

If a network error occurred, this property is true; otherwise false. If true, the response property of the event will contain a description of the error.

Note that a 404 response is not a network error. The network request succeeded but the requested item cannot be found on the server. Network errors indicate that it isn't possible to contact the server for reasons such as the server is down or its name is incorrect.

Example

local function networkListener( event )
    if ( event.isError ) then
        print( "Network error: ", event.response )
    else
        print( "RESPONSE: " .. event.response )
    end
end

postData = "color=red&size=small"

local params = {}
params.body = postData

network.request( "http://127.0.0.1/formhandler.php", "POST", networkListener, params )