When I test my application, it returns some specific data, but when the requested data is null, this unhandled exception error appears
ItriedtocapturehimbutIthinkI'mwrong.HowcanIleaveatreatmentthatwarnsinatextboxthattherequesteddatawasnotfound?
'BuscarinformaçõesviaGoogleBookAPI(precisaserarrumado)'PrivateSubButton3_Click(senderAsObject,eAsEventArgs)HandlesButton3.Click'Step1:-googleAPIurlresponsibleforreturningthebookdetailinJASONformat'ConstGOOGLEAPIURLAsString="https://www.googleapis.com/books/v1/volumes?q="
If Me.txtISBN.Text <> String.Empty Then
Dim requestURL As String
'Step 2:- Reformed the URL to target particular ISBN number'
requestURL = GOOGLEAPIURL + Me.txtISBN.Text.Trim() + "+isbn"
'Step 3: created Http webrequest for URL'
Dim wr As HttpWebRequest = HttpWebRequest.Create(requestURL)
'Step4 : get the response of web request in http web response object'
Dim resp As HttpWebResponse = wr.GetResponse()
'Step 5: passes the response stream in stream reader'
Dim sreader As New StreamReader(resp.GetResponseStream())
'Step 6: parsing the reader(which is in Jason format) using JASON.NET'
Dim rss = JObject.Parse(sreader.ReadToEnd())
'Step 7: if object find the fetch the detail'
If rss Is Nothing = False AndAlso rss.Count > 0 Then
Me.lblBookName.Text = rss.Item("items")(0).Item("volumeInfo").Item("title").ToString()
Me.lblSubtitle.Text = rss.Item("items")(0).Item("volumeInfo").Item("subtitle").ToString()
Me.lblAuthor.Text = rss.Item("items")(0).Item("volumeInfo").Item("authors").ToString().Replace("[", "").Replace("]", "").ToString()
Me.lblPublisher.Text = rss.Item("items")(0).Item("volumeInfo").Item("publisher").ToString()
Me.lblPublishedDate.Text = rss.Item("items")(0).Item("volumeInfo").Item("publishedDate").ToString()
Me.lblPageCount.Text = rss.Item("items")(0).Item("volumeInfo").Item("pageCount").ToString()
'Captura de erro'
Try
rss = True
Catch ex As Exception
End Try
Else
MsgBox("Nada aqui")
End If
Else
Me.lblMessage.Text = "Please enter the ISBN number"
End If