Bug? Library OkHttpUtils2.b4xlib version 7.28 (Error Reason field)

bridge1

Member
Then method HttpUtils2Service.hc_ResponseError NOT adding in the error description the Reason if Response.ErrorResponse is filled (also possible with just the space character) , is it possible to update the library with this change?

This would allow us to analyze even errors that only have the field "Reason" filled.


Samples log response message only with Reason:
"ResponseError. Reason: java.net.ConnectException: Failed to connect to /10.10.10.10:12312, Response: "


Method HttpUtils2Service.hc_ResponseError:
Sub hc_ResponseError (Response As OkHttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    #if Not(HU2_NOLOGS)
    Log($"ResponseError. Reason: ${Reason}, Response: ${Response.ErrorResponse}"$)
    #end if
    Response.Release
    Dim job As HttpJob = TaskIdToJob.Get(TaskId)
    If job = Null Then
        Log("HttpUtils2Service (hc_ResponseError): job completed multiple times - " & TaskId)
        Return
    End If
    job.Response = Response
    If Response.ErrorResponse <> "" Then
        CompleteJob(TaskId, False, Response.ErrorResponse)
    Else
        CompleteJob(TaskId, False, Reason)
    End If
End Sub

Hypothesis of modifying the method:
Sub hc_ResponseError (Response As OkHttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    #if Not(HU2_NOLOGS)
    Log($"ResponseError. Reason: ${Reason}, Response: ${Response.ErrorResponse}"$)
    #end if
    Response.Release
    Dim job As HttpJob = TaskIdToJob.Get(TaskId)
    If job = Null Then
        Log("HttpUtils2Service (hc_ResponseError): job completed multiple times - " & TaskId)
        Return
    End If
    job.Response = Response
    If Response.ErrorResponse.Trim <> "" Then
        If Reason.Trim <> "" Then
            CompleteJob(TaskId, False, Response.ErrorResponse & " Reason: " & Reason)
        Else 
            CompleteJob(TaskId, False, Response.ErrorResponse)
        End If
    Else
        CompleteJob(TaskId, False, Reason)
    End If
End Sub


Thanks,
we look forward to hearing from you,
or some workaround to the problem.
 
Top