Android Question Get Message with HttpUtils2

Luiz Fernando Orlandini

Active Member
Licensed User
Longtime User
Hi All.

I'm getting some difficulty with get the error message when I got an InternalServerError, from my REST service that is in the environment of my application.

My REST Service is using Jersey library (JAVA), and InternalServerErrors generated by an the code, following the best practices.

B4X:
public class CustomInteralErrorServerException extends WebApplicationException {

    private static final long serialVersionUID = -8122413512746549653L;

    public CustomInteralErrorServerException() {
        super(Response.noContent().build());
    }
   

    public CustomInteralErrorServerException(String message) {
        super(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).header("Content-Type", "text/plain;charset=UTF-8").build());
      }
}

When some error occurs, the HttpJob, throws the error, but when I get the message using,

B4X:
If Job.Success Then
        Log(Job.GetString)
        Select Job.JobName
            Case "AcceptOrder"
                AcceptOrder_Success
Else
        Log(Job.ErrorMessage)
       
        Select Job.JobName
            Case "AcceptOrder"       
                AcceptOrder_Fail
        End Select
    End If
   
    Job.Release
End If

The Log, register the follow message: InternalServerError.

Is there any way of get the message that was throw by the exception class of my REST sercive?

If I use SoapUI to test the service, I can see that occurs an InternalServerError, but the message was there, in the response.

Regards.
 

Luiz Fernando Orlandini

Active Member
Licensed User
Longtime User
Erel, I'm not sure if I understand.

I have to uncheck the library in my project and also create the code module with the same name, because I have to do some customization in hc_ResponseError method. Am I rigth?

Once I started to use HttpUtils2Service, Do you have some tricks that I have to implement?

Thanks.
 
Last edited:
Upvote 0

Luiz Fernando Orlandini

Active Member
Licensed User
Longtime User
Erel, I did this update in the code module.

What do you think?

B4X:
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
    Dim ReasonMessage As String
 
    If Response <> Null Then
        Try
            Log(Response.GetString("UTF8"))
            ReasonMessage = Response.GetString("UTF8")
        Catch
            Log("Failed to read error message.")
            ReasonMessage = Reason
        End Try
     
        Response.Release
    End If
 
    CompleteJob(TaskId, False, ReasonMessage)
End Sub
 
Upvote 0
Top