Results 1 to 3 of 3

Thread: [RESOLVED] Why the Warning with my 'try catch finally end try' code?

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Megalith's Avatar
    Join Date
    Oct 2006
    Location
    Secret location in the UK
    Posts
    879

    Resolved [RESOLVED] Why the Warning with my 'try catch finally end try' code?

    Why do i get a warning with my http? Trying to come to terms with try catch finally end try
    Code:
            Dim myhttp As HttpWebRequest
            Dim html As String = ""
            Dim responseStream As Stream
            Dim WebResponse As HttpWebResponse
            Try
                myhttp = CType(WebRequest.Create(url), HttpWebRequest)
                WebResponse = CType(myhttp.GetResponse(), HttpWebResponse)
                responseStream = WebResponse.GetResponseStream()
                Dim reader As StreamReader = New StreamReader(responseStream, Encoding.Default)
                html = reader.ReadToEnd()
    
            Catch ex As HttpException
                MsgBox("Validation HTTP error" & vbCrLf & ex.Message)
            Catch ex As NullReferenceException
                MsgBox("Null value returned error")
            Catch ex As Exception
                MsgBox("Validation Other Exception error" & vbCrLf & ex.Message)
            Finally
                responseStream.Close()
            End Try
    the code in the finally block to close the stream that may or may not have produced an error gives me a warning that the code may produce a null value, even with both an exception handler and with a null value handler.

    I read about using nested try catch end try and wonder if i should try again if i get an error. Is it possible to say do the block if it errors give the user the option to try again or abort the app?

    (afterthought this is sending an encrypted string to a server to validate before the app gives full access)
    Last edited by Megalith; Jan 3rd, 2010 at 10:12 PM.
    If debugging is the process of removing bugs, then programming must be the process of putting them in.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width