native.showWebPop - when it is bad to catch errors

Hi All,

It turns out that sometimes it is bad to catch errors using the urlRequest callback.

In GoYeti, I have been implementing simple Facebook functionality. I did not want to implement the full Facebook API, but merely wanted users to like the Facebook page.

To start with I used the following code:

local function webListener( event )  
 local shouldLoad = true  
  
 if event.errorCode then  
 -- Error loading page  
 native.showAlert( "Error loading page",   
 tostring( event.errorMessage ), { "OK" } )  
  
 shouldLoad = false  
 end  
  
 return shouldLoad  
end  
  
native.showWebPopup(0.025\*N, 0.029\*H, 0.95\*N, 0.94\*H,"http://m.facebook.com/goyetigame", { urlRequest = webListener });  
  

The first four arguments to native.showWebPopup just set a rectangular box slightly smaller than the screen size.
N and H are set to the screen width and height.
Since you cannot place objects in front of the native view, I use a close button on the top-right hand corner, which is just a cross with an event listener behind.

Everything is find until you try to log in to Facebook. For some reason, the event listener returns an error. After scratching my head for a long time, I realised that the log-in is actually successful, but for some reason the event listener still returns an error. Hmmm

After trialling methods to automatically relaunch the web pop-up after catching an error, it struck me that I should used the following code

local function webListener( event )  
 return true  
end  

i.e. don’t catch the errors at all!
This works perfectly. The user can log in properly. If there are any errors then the user can just close the web view using the red cross.

I can’t see any drawback with this method, and with around 2 days to go before submitting the app, I’m keeping my fingers crossed :slight_smile:

Anthony
www.nevistech.com [import]uid: 87194 topic_id: 32016 reply_id: 332016[/import]