Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo Zusammen,

ich habe im folgendem Code-Schnipsel das Problem, dass wenn der Facebook Graph

den HTTP Fehlercode 400 zurück gibt, dass das Programm dann abstürzt. Wenn die Antwort

vom Facebook Graph 200 ist, läuft das Programm ohne Probleme.

Könnt Ihr mir sagen wieso das Programm abstürzt bzw. wie ich dies abfangen kann?

Ich habe schon versucht mit

IF hres.StatusCode() = 200 Then

normal ablaufen

Else

Programm beenden

End IF

Aber das Programm stürzt trotzdem ab.

      

ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf AcceptCert)

        Dim args() As String = Split(Command(), " ", -1)

        Dim sURL As String = "https://graph.facebook.com/" & args.GetValue(0) & "?fields=id,likes"

        Dim ssave As String = args.GetValue(1) & "\antwort.txt"

        TextBox1.Text = sURL

        TextBox2.Text = ssave

        Dim hreq As HttpWebRequest = CType(HttpWebRequest.Create(sURL), HttpWebRequest)

        Dim hres As HttpWebResponse = CType(hreq.GetResponse(), HttpWebResponse)

        Dim s As Stream = hres.GetResponseStream()

        Dim sr As New StreamReader(s)

        Dim html As String = sr.ReadToEnd() & vbCrLf

        sr.Close()

        s.Close()

        File.WriteAllText(ssave, html)

        Close()

  • Autor

Da ich kein richtiger Programmierer bin, kannte ich die Funktion On Error nicht und ja es gibt so eine.

On Error-Anweisung (Visual Basic)

@hbspike Nein, wenn ich mir die URL im Browser aufrufe, erhalte ich eine Antwort vom Webserver mit einer Fehlermeldung.

Dies kann aber verschiedene Gründe haben, aber den gleichen Fehler zurückgeben.

Aber unterm Strich kann ich jetzt den Error abfangen und weiterverarbeiten. Danke für eure Vorschläge.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.