debugging - C# Exceptions Not Being Handled -


the following code called via browser , if exception occurs exception never caught 'try catch' instead exception reported screen. have tried running without debug turning off clr errors. suggestions appreciated:

   public string geturl(string url)     /*grab remote page */     {          string target = string.empty;         httpwebrequest httpwebrequest = null;         httpwebresponse response = null;         streamreader streamreader = null;         try         {          httpwebrequest = (httpwebrequest)webrequest.create(url);         response = (httpwebresponse)httpwebrequest.getresponse();         streamreader = new streamreader(response.getresponsestream(), true);                  target = streamreader.readtoend();            }         catch (webexception e)         {             console.writeline("error:geturl()");             console.writeline("\n{0}", e.message);             console.writeline("\n{0}", e.status);         }                  {             streamreader.close();                 response.close();          }          return target;       } 

you catching webexceptions, other exception not caught.

it can throw more exceptions see here :

https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse%28v=vs.110%29.aspx


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -