how to trap http errors

cwt

Active Member
Licensed User
Longtime User
I have done a search and could not find any definitive answers regarding this - I am creating a soap client and would like to display to the user a more meaningful message than the java runtime error message when the client cannot connect to the server.

Just a simple "cannot connect to server" instead of the runtime error. How can I trap the runtime error so I can substitute my own message?

Thanks
 

cwt

Active Member
Licensed User
Longtime User
My soap server is in-house and the Android app I am creating is only for in-house use. If the soap server is not on line when I post an http soap packet (using HttpUtils) then the Android app gives a java runtime error message -

java.lang.RuntimeException:
Object should first be initialized (InputStream)...

Is this something I can trap and substitute my own message for?

By the way - I have been programming for over 30 years and this is my first dive into Java and Android - I have used a lot of IDEs and RADs and your product is superb. I would recommend it to anyone.

Thanks
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I don't know how your code is but can't you initialize your code in the JobDone-sub? Something like:

B4X:
Select Job
   Case "JOB_ExecuteCommand"
      If HttpUtils.IsSuccess(URLcmd) Then
         'for instance parserE2MovieLocations.Initialize
      End If
End Select

Also in HttpUtils in the sub HandleError you can do something like this:

B4X:
Sub HandleError(TaskId As Int, Reason As String)
   Dim link As String
   link = taskToRequest.Get(TaskId)
   Log("Error. Url=" & link & " Message=" & Reason)
   ToastMessageShow("Connection-error!" & CRLF & "Check your connection and/or settings and try again.",True)
      StartActivity(HttpUtils.CallbackActivity)
   

End Sub
 
Upvote 0

cwt

Active Member
Licensed User
Longtime User
Thanks - I found the error message was being produced by the xml parser.initialize call. Have it fixed. Thanks again
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…