I think slowly ;-). When I read the thread I was left with the impression that Try-Catch was only debug mode, which is incorrect. I wanted to make it clear to subsequent readers that it works with release versions as well. But yes, after I posted, I realized that the array explanation had been pointed out by Dreamora. And I agree: more examples are needed, as well as examples of creating custom exception objects. So, here's one:
And it's thrown like this:
and caught like this:
Type invalidValueException Extends TBlitzException field msg:string = null Method toString:String() if msg then return msg else return "Invalid value!" End Method End Type
And it's thrown like this:
function strToBool:byte(s:string) select s.toLower().trim() case "true" return True case "false" return False default local e:invalidValueException = new invalidValueException e.msg = "Bad value passed: " + s Throw e end select end function
and caught like this:
try b = strToBool(s) catch ex:invalidValueException print ex.toString() ' Do some error recovery things here catch ex:object ' Catch other exceptions print ex.toString() ' Do some other things here end try