Jun 20, 2014 at 10:05 AM
Edited Jun 20, 2014 at 10:08 AM
first of all, I love the FlickrNet Library. It is straight forward and very easy to use - thanks a lot to everybody involved!
I am having a problem with my program and maybe one of you knows an answer:
Occasionally, Flickr.photos.search returns an Exception "(502) Bad Gateway.". I believe it is because I am using the Try...Catch...Finally Statement that I am able to see this error at all.
However, I would like my program to continue processing - if 502-Error occurs, it should just try repeating the last request and go on.
How can I catch this specific Error in VBNet?
This is the full error message:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Net.WebException: WebException occurred with the following body content: <!DOCTYPE html>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimal-ui">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%;
font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif;
<!-- status code : 502 -->
<!-- Server Connection Closed rw.api.flickr.com -->
<!-- host machine: r18.ycpi.ams.yahoo.net -->
<img src="https://s.yimg.com/nn/img/yahoo-logo-201402200629.png" alt="Yahoo Logo">
<h1 style="margin-top:20px;">Will be right back...</h1>
<p id="message-1">Thank you for your patience.</p>
<p id="message-2">Our engineers are working quickly to resolve the issue.</p>
---> System.Net.WebException: The remote server returned an error: (502) Bad Gateway.
Jun 20, 2014 at 10:46 AM
You just have to wrap your code in a loop, and have a Catch(exception As WebException) statement (if I got my VB.Net correct).
Jun 21, 2014 at 2:45 PM
Edited Jun 21, 2014 at 2:45 PM
Thank you, Sam. I had a Try.. Catch.. Loop, but it somehow did not catch the error. I revised this part of code and it now looks like this:
Dim Photos As PhotoCollection = f.PhotosSearch(options)
Catch ex As FlickrException
Outputtextbox.Text &= "Error occured: " & ex.ToString
Until now, no Webexception occurred, but I will write here if it worked out.. . Thanks a lot for your advice!
Jun 21, 2014 at 3:38 PM
Edited Jun 21, 2014 at 4:57 PM
Hm, this did not work.. I still get the error 502 and my program aborts:
Is it possible that this exception is not part of FlickrException?
Of course.. its System.Net.WebException and not FlickrException!
Too tired.. ;) Problem solved. Thank you!