How to handle exception in WP7

Topics: Developer Forum, Project Management Forum, User Forum
Apr 19, 2012 at 7:09 AM

Hi,

Thanks for your support first, about following search method it will return an error sometimes,but not every time.

the error message is "Value can not be null.\r\nParameter name: messageBoxText" and The remote server returned an error: NotFound.

I have no idea why it happens, maybe it is webexception, but how I can I handle it, could you please give me a hand?

 flickrHelper.flickr.PhotosSearchAsync(photoSearchOptions, (callback) =>
            {
                if (callback.HasError == true)
                {
                    MessageBox.Show(callback.ErrorMessage);
                }
                else
                {
                    foreach (var i in callback.Result)
                    {
                        SearchPhotos.Add(i);
                    }
                    if (action != null)
                    {
                        action();
                    }
                }

            });

 

Thanks,

Bean

Coordinator
Apr 19, 2012 at 7:58 AM

ErrorMessage is specific to the Flickr API. If you are getting a generic WebException then you would need to check the callback.Error exception class for the error.

In theory callback.ErrorMessage and callback.Error.Message will be the same when the error is a Flickr API error, but callback.ErrorMessage will be blank for other exceptions.

Apr 19, 2012 at 8:20 AM

Yes, I always met the other exceptions, the ErrorMessage is blank, do you have idea how to handle this exception. and why this kind of exception happens?

Thanks,

Bean

Coordinator
Apr 19, 2012 at 8:22 AM

No, I don't. What is the WebException?

Apr 19, 2012 at 8:32 AM

okay, To be honest, I have no idea what is WebException exactly, I think it is the network problem, and the reason is not clear.

thank you again