WebView: how to catch 404 (or other) error ?

lagore

Active Member
Licensed User
Longtime User
Hi
You can catch all of the HTTP errors in the "hc_ResponseError" sub of the "HttpUtilsService" module I needed to do this for a redirect problem which is a 302 error code. Just put in your own code for which ever type of error you want to handle.
B4X:
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
   countWorking = countWorking - 1
   finishTasks = finishTasks + 1
   HandleError(TaskId, Reason)
   If Response <> Null Then
      Log(Response.GetString("UTF8"))
      Response.Release
   End If
      
   Log("Error")
    Log(StatusCode)
    If Floor(StatusCode / 100) = 3 Then '3xx status
        If Response <> Null Then
            Log("Redirect to: " & Response.GetHeaders.Get("Location"))
         
        End If    
    End If
   
   
   ProcessNextTask
End Sub
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, Lagore, but WebView as a browser is interesting, not direct HTTP connections (i know about it)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Yes, Erel, already using WebViewXtender - very good lib, just HTTP errors catching is missing :)
Roeschti, possible to add, please ?
 
Upvote 0
Top