Android Question capturing lastexception.message

drgottjr

Expert
Licensed User
Longtime User
i'm familiar with "errormessage" in the httpjob module, but i'm trying now to capture the "lastexception.message" that i see referred to here in the forums. it just seems to appear, as if by magic, as a toast message when an exception occurs. i've tried to reference it in a msgbox within the "catch" part of "try ... catch", but the msgbox never appears. only the system-generated toast message. is catch not supposed to catch the message?

specifically, i set a timeout for an http getrequest. that part works fine: a toast message appears and signals the timeout ("java net socket timeout exception"). how do i get to see that message before it appears as a toast message?

examples i've seen here just use lastexception without out previous declaration (that i've noticed). is it supposed to be dim'd? i tried that, and it threw its own build error.

-go
 

DonManfred

Expert
Licensed User
Longtime User
In jobDone sub you have something like

B4X:
Sub JobDone(Job As HttpJob)
    ProgressDialogHide
    If Job.Success Then
        ' do something
    Else
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release
End Sub
and instead of calling
B4X:
ToastMessageShow("Error: " & Job.ErrorMessage, True)
you can log the ErrorMessage
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
thanks for the replies. i apologize; perhaps i wasn't clear. i'm making a distinction between "error" and "exception".

i already use job.errormessage within the jobdone sub. no problem as far as that goes. unfortunately, an exception is not captured there, only an "error". exceptions are, apparently, trapped elsewhere by the system.

also, i am not the one calling the toast message; it simply appears when the exception occurs.

i have seen references to the exceptionex library, and i will look into it, but i don't understand why i can't reference lastexception.message at some appropriate moment, eg within a try-catch-end try block? and, in case my use of msgbox is causing the issue, i've also tried to log the lastexception.message within catch. nothing.

if the timeout exception were not an exception i wouldn't be asking about lastexception.message, but the toast message i see says it is an exception (java socket timeout exception). i've looked in the httpjob and http2utils modules, but i don't see anything to indicate they're calling the toast message.

-go
 
Upvote 0
Top