Wish Error handling (resume next)

WimS

Member
Licensed User
The one (and only) way of error handling is now 'Try Catch'.

While an error occured, Try jumps to Catch out of the code flow : the code flow ends on the line with the error.

I have so many code to written with database reads and string handles etc etc. At now I must check everything (consist, empty, zero etc etc). Must I write Try Catch for every code line who can probably generate an errror?

Please, if there is a possibility to add a way of error handling that will resume the code flow (like resume next), you will make me very happy.

B4A is great! But for all B4A can, the error handling is too small in me opinion ;-)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
On Error Resume Next is not something that should be implemented in production. This is completely uncontrollable and I don't see any good reason to use such feature.

Must I write Try Catch for every code line who can probably generate an errror?
Why are there errors? Please give us an example.

If there is an error it is better to rollback the transaction and keep the database not corrupted.

https://www.b4x.com/android/help/sql.html#sql_begintransaction

It requires exactly one Try / Catch block.
 

WimS

Member
Licensed User
Ok.

See below how I works

If StringFuncties.IsNull(Str) Then
Str = ""
Else
Str = RegCursor.GetString("GeboorteDatum")
Str2 = RegCursor.GetString("EindDatum")
DateTime.DateFormat = "dd-MM-yyyy"
If StringFuncties.Is0(Str2) Then
Str2 = DateTime.Date(DateTime.Add(DateTime.Now,0,0,1))
Str = Algemeen.DaysBetween(Str,Str2)
Else
Str2 = DateTime.Date(DateTime.Add(DateTime.DateParse(Str2),0,0,1))
Str = Algemeen.DaysBetween(Str,Str2)
End If
End If
pdf.Canvas.DrawText(Str, l+416, t, Typeface.DEFAULT, fs1/ GetDeviceLayoutValues.Scale , Colors.Black , "CENTER")

Error on Null String :
(NullPointerException) java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference
 
Top