Libraries and error handling

William Hunter

Active Member
Licensed User
Longtime User
I have tried to trap error messages, thrown by a library, with a Try/Catch Block. This doesn’t work.

When attempting to logon, or while logged on, to a mail server the Net library might throw such errors as: Error during login - Error getting status - Error getting identifier - Error deleting message.

Is there a means of trapping these errors, at the moment of occurrence, so that they can be dealt with in a meaningful way?

Any help with this would be greatly appreciated.
 
Last edited:

William Hunter

Active Member
Licensed User
Longtime User
You can then get the exception with LastException object.

Thank you for your reply. I’m using the wPOP library in my project quite successfully. I have tried using the LastException object, as a means of trapping login errors without success. If I try to use it such as in the snippet below, I always get the error: “java.lang.RuntimeException: Object should first be initialized (Exception)” at line 3. Yet, when I don’t use this error check, I logon successfully and all is well. I’m finding error handling with Android to be a bit confusing.

B4X:
Sub ShowLastException
   Dim EX As String
   Dim stripEX As String
   EX = LastException.Message ' this is line 3
   stripEX = EX.SubString(28)
   Msgbox(stripEX, "Login error")
End Sub
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
Where is the code that calls this sub?
Hello Erel – That error occurs directly after login, before the execution of any other B4A code. Logging for LastException directly before login does not trap this error. This is a wPOP error. While it interferes with my attempts at error handling, wPOP seems to function OK if I ignore it. This is why I say Android error handling confuses me.

Regards
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…