B4J Question Why is Try Catch mechanism doesn't works?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I have this codes :
B4X:
Sub Process_Globals
    Private Conn As String
    Private reqM As DBRequestManager   
End Sub

Sub ExecQ(Command As String, Params() As Object) As Boolean
    If(reqM.IsInitialized = False) Then reqM.Initialize(Me, Conn)

    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Command

    Try
        If(Command = "ins_tmp") Then
            cmd.Parameters = Params
            reqM.ExecuteQuery(cmd, 0, Command)
            Log(1)
            Return True
        End If
    Catch
        Log(LastException)
        Log("err on connect!")
        Return False
    End Try
End Sub

This is an implementation on jRDC on B4J. Tested while server was down.

Since the server was down, the Sub ExecQ, should return a false value, but instead, it always return true.

Anyone know what's wrong with those codes?

Thanks in advance.
 

incendio

Well-Known Member
Licensed User
Longtime User
Never mind, just found the reason. It was an asynchronously operation, should trap the error on the Sub JobDone.
 
Upvote 0
Top