B4A Class Exception, raise, log and format


Sometimes you need to stop a piece of code and explain why you have to do it.

A good way is to raise an exception and to give information about the reason why.

This little class offers you a pratical way to do this :
1) Add the class to your project

2) Declare an instance of the class:
Public fException As clsException
Declare the instance in the starter module is a good idea

3) Raise an exception:
Starter.fException.raise("Main","fButton_Click",1,$"Too big : (${i})"$,True)
You pass the module, the method, an erorr number, an error message and say if you want to log the exception.

4) Display information to the user:
wait for (fXUI.MsgboxAsync(Starter.fException.info,"Exception")) msgbox_result(result As Int)
screen 1.png

Class and example in the zip archive



  • exception.zip
    9.8 KB · Views: 228