Throw (error As Object) The throw statement allows you to create a custom error.
Technically you can throw an exception (throw an error).
e.g. BANano.Throw("This number is not valid")
BANano.Throw(500)
A full example is with the extra BANano.Finally keyword (because the try - catch in B4J does not have that statement, but is often handy)
B4X:
Dim num As Int = 10
Dim divider As Int = 0
Try
If divider = 0 Then
BANano.Throw("You can not divide by 0!")
Else
Log(num/divider)
End If
Catch
Log(LastException)
' will still do the Finally part, but not the "After the Try" log.
Return
BANano.Finally 'ignore
Log("Always doing this")
End Try
Log("After the Try")