Android Question Idea. Add Code automatic to all SUB.

netsistemas

Active Member
Licensed User
Longtime User
If in old sub, i insert, automatic (proyect in .net or simil), and in all code files this code (CAPITAL LETERS are code to autgenerate):
B4X:
sub my code

TRY

        ...

        ...

        ...

        Try

        catch

        end try



CATCH

 'MY FUNCION CONTROL ERROR'

END TRY


is good idea or not?
 

agraham

Expert
Licensed User
Longtime User
Handle the unhandled exception event instead.
I now always put a handler in Starter.Application_Error. As I rarely use Debug mode it will catch and report errors that otherwise just close the app with no indicaton of what went wrong and as a bonus the app keeps running so you can do it all over again :)
B4X:
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    ToastMessageShow(Error.Message, True)   
    LogColor("Application Error" & CRLF & Error.Message, Colors.Red)
    Return False
    'Return True   
End Sub
 
Upvote 0
Top