This project has moved and is read-only. For the latest updates, please go here.

How To Catch Errors and Failures In FlickrNet API calls?

Topics: Developer Forum
Sep 6, 2012 at 4:30 PM


I am a very new programmer. I write code in Visual Basic 2010. I have successfully used this WONDERFUL FlickrNet API. It is VERY well done!

I have figured out from reading all the postings on here and on the Flickr API discussions with Sam Judson, that the quries were limited to 4,000 results and also how to use the "PhotoSearchExtras" to get additional parameters from the search results. It all works great!

I just want my code to not fail at run time due to network problems or flickr service problems. My question is this:

How can I make sure that I trap on failures of the FlickrNet API calls and verify that I get proper results back or an error code that I can trap on? Is there some kind of Try / Catch type of setup I should use here?

I do not want my code to fail at run-time so I want to try to anticipate all the possible problems here.

Thanks so much for any help you can give me! This really is a very cool way of interfacing with the Flickr service's API rather than having to make the REST API calls directly!

Jean-Marie Vaneskahian

Sep 9, 2012 at 2:02 PM

Yeah, try/catch would be your best bet - unless you are using the Async methods, in which case you'll want to check the HasError and Error properties of the FlickrResult instance passed to the callback method.


Sep 11, 2012 at 3:06 AM
Edited Sep 11, 2012 at 3:07 AM

Sam, I am really new at this. Though I understand the concept of the Try / Catch statements, I am not sure how to apply them here. My calls will synchronous (I think...)... Here is a sample of my code. How would I trap on errors here?

    Public FlickrAPIKey As String = "7c7b590d482b6c20c08fcaa3b92188f0"
    Public Sub GetPhotosFromFlickrBasedOnDateRange(ByVal UserID As String, ByVal FlickrPhotoTags As String, ByVal MinUploadDate As Date, ByVal MaxUploadDate As Date)
        Dim FlickrConnectionObject As Flickr = New Flickr(FlickrAPIKey)
        Dim FlickrSearchOptions As PhotoSearchOptions = New PhotoSearchOptions()
        FlickrSearchOptions.UserId = UserID
        FlickrSearchOptions.Tags = FlickrPhotoTags
        FlickrSearchOptions.MinUploadDate = MinUploadDate
        FlickrSearchOptions.MaxUploadDate = MaxUploadDate
        FlickrSearchOptions.Extras = PhotoSearchExtras.DateTaken Or PhotoSearchExtras.DateUploaded Or PhotoSearchExtras.OriginalDimensions
        FlickrSearchOptions.PerPage = 50
        FlickrSearchOptions.MediaType = MediaType.Photos
        FlickrSearchOptions.ContentType = ContentTypeSearch.PhotosOnly
        FlickrSearchOptions.TagMode = TagMode.AnyTag
        Dim AllFlickrPhotosFromThisSearch As New List(Of Photo)()
        FlickrSearchOptions.Page = 1
        Dim FlickrSearchResuts As PhotoCollection = FlickrConnectionObject.PhotosSearch(FlickrSearchOptions)
        Dim TotalPhotosInThisSearch = FlickrSearchResuts.Total
        Dim TotalPagesInThisSearch = FlickrSearchResuts.Pages
    End Sub
I want to make sure I get a proper response / no errors back for:
  • FlickrConnectionObject
  • FlickrSearchResuts
  • (all the Flickrnet methods)


What is it that needs to be examamined to ensure that that there was not an error?









Sep 11, 2012 at 2:46 PM

Learn about Try Catch here:

It should only be the call to PhotosSearch that should ever raise an error.