Much like a HTML parser, UfXtract fails quietly during the parsing process. The UfWebRequest class does throw exceptions if it has problems finding a Url. You can catch these exceptions and handle them yourself or pass them through to the data convertors using the UfErrors collection object.
string url = "http://www.xxxxxxxxxx.yyy/"; UfWebRequest webRequest = null; UfErrors errors = new UfErrors(); try { webRequest = new UfWebRequest(); webRequest.Load(url, UfFormats.HCard()); } catch (Exception ex) { if(webRequest.Urls.Count > 0) errors.Add(new UfError(ex.Message, url, webRequest.Urls[0].Status)); else errors.Add(new UfError(ex.Message, url)); } UfDataToJson dataConvertor = new UfDataToJson(); Response.ContentType = "application/json"; //Add reporting and errors dataConvertor.Urls = webRequest.Urls; dataConvertor.Errors = errors; Response.Write(dataConvertor.Convert(webRequest.Data, UfFormats.HCard()));
© 2007-2010 Glenn Jones. All Rights Reserved.