display.loadRemoteImage issue

How to handle a failed loadremoteimage call? Is it possible to assign a new image file inc ase the download fails?

Sample Code

local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
else
event.target.alpha = 0
transition.to( event.target, { alpha = 1.0 } )
if event.target ~= nil then

      local myimg= event.target
      myimg.name =  event.response.filename
      myimg.height=48
      myimg.width=60
	 myimg.anchorX=0
     groupItems:insert(myimg)

    else
      print("Error Loading")
    end
end

end

display.loadRemoteImage(itemPhoto, “GET”, networkListener, itemID … “.jpg”, system.TemporaryDirectory,posPhotoX, posPhotoY )

the problem is you need to know what the real problem is:

is it the internet connection on your side?
does the image you are looking for really exist? (might have been deleted from server or server unavailable)
did downloading get disconnected or timed out?

based on the scenario you would want to call the command again to load remote image or ask user to turn on internet connection or try later when server is back online

Look at the code of the function that I use; it handles err 404 and other very well. Though yours HTTP-STATUS-LINE could be different. I use my own server responce in that case.