Hello
I do something like this:
-User fills in credentials and presses login button
-An API method is called with the credentials and returns a token, or an error
If API call is succes:
-The API method extracts the bearer token from json result and returns it
If API call fails:
-The API method extracts the error message from json error (if any, otherwise some generic message), assembles a ExceptionEx with the error message and throws that exception.
In the loginbutton click I want to catch that said Exception and show the message to the user. See code:
The problem is, it seems to be impossible to catch this exception. It is always displayed in the logs (so before it reaches my Try)
My guess is that ABMaterial catches this error before I can. But where? Where can I pass it along instead of just displaying it to the logs?
I tried searching for 'LastException' as I hoped I could trace the source, but I'm not getting the results I'm hoping for. (only my own references, and in the ABMupload class, which I don't currently use)
@alwaysbusy I think you're the only one that knows this answer?
Thanks a bunch
I do something like this:
-User fills in credentials and presses login button
-An API method is called with the credentials and returns a token, or an error
If API call is succes:
-The API method extracts the bearer token from json result and returns it
If API call fails:
-The API method extracts the error message from json error (if any, otherwise some generic message), assembles a ExceptionEx with the error message and throws that exception.
In the loginbutton click I want to catch that said Exception and show the message to the user. See code:
B4X:
Public Sub btnlogin_Clicked(Target As String)
Dim loginContainer As ABMContainer = page.Component("containerlogin")
Dim usernameInput As ABMInput = loginContainer.Component("txtusername")
Dim passwordInput As ABMInput = loginContainer.Component("txtpassword")
Try
Wait For(API.PerformLogin(usernameInput.Text, passwordInput.Text)) Complete (bearer As String)
page.ws.Session.SetAttribute("bearer_token", bearer)
ABMShared.NavigateToPage(page.ws, page.GetPageID, "../DashboardPage")
Catch
usernameInput.Text = ""
usernameInput.SetFocus
usernameInput.Refresh
passwordInput.Text = ""
passwordInput.Refresh
Dim errorLabel As ABMLabel = loginContainer.Component("lblError")
errorLabel.Text = LastException.Message
errorLabel.Visibility = ABM.VISIBILITY_ALL
errorLabel.Refresh
End Try
End Sub
The problem is, it seems to be impossible to catch this exception. It is always displayed in the logs (so before it reaches my Try)
My guess is that ABMaterial catches this error before I can. But where? Where can I pass it along instead of just displaying it to the logs?
I tried searching for 'LastException' as I hoped I could trace the source, but I'm not getting the results I'm hoping for. (only my own references, and in the ABMupload class, which I don't currently use)
@alwaysbusy I think you're the only one that knows this answer?
Thanks a bunch