Android Question Try Catch as On Error Resume Next

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Trying to handle null values in this loop:

B4X:
    Dim arrRow() As String
    Dim arrColInt(Data.Size) As Int
    For i = 0 To lUB
     arrRow = DataTemp.Get(i)
     Try
      arrColInt(i) = arrRow(col)
     Catch
      'just do nil as QSort1DInt_IDX can cope with nulls
     End Try
    Next

This works perfectly fine as I know what throws the error (null values) and it fine to have an empty array element (arrColInt(i))
So, this works as an On Error Resume Next and can't see any problem with it. Still, the IDE is not happy with this:
Empty Catch block. You should at least add a log.
Is there anything wrong with this? Would there be any mileage in having On Error Resume Next (+ On Error GoTo 0) and avoid
the IDE warning?

RBS
 

OliverA

Expert
Licensed User
Longtime User
and avoid
the IDE warning?
Just block the warning with an 'ignore
B4X:
     Try
      arrColInt(i) = arrRow(col)
     Catch
      'just do nil as QSort1DInt_IDX can cope with nulls
     End Try 'ignore
There are always exceptions to the rule and you've made your case, so ignore the warning (and hide it with 'ignore)
 
Upvote 0
Top