B4J Question User Defined Exception

nbarakat

Member
Hello All,

Is it possible to generate a user defined exception in B4J?

Pseudocode:
Try
    If Condition then
        GenerateException
    end if   
    continue normal flow
Catch
  ...
End Try

Thanks
 

nbarakat

Member
Thanks Erel for the pointer. Works great! Below is an example for people that are interested...

B4X:
Sub Process_Globals
    Private UserError As ExceptionEx
End Sub

Sub AppStart (Args() As String)

    Dim triggerError As Boolean = True
   
    Try
        If triggerError Then
            UserError.Initialize("Error Triggered")
            UserError.Throw  
        End If
    Catch
        Log(UserError.Message)
        Log(LastException)
    End Try

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