User Tools

Site Tools


exceptions

This is an old revision of the document!


Exceptions

As already described in the topic Try - Catch the .NET Framework uses exceptions to notify about an error condition.

Take as sample the String:SubString() method:

local cString as string
local cResult as string

cString := "Hello world"
cResult := cString:Substring( 5, 30 )

Since the string is less than 35 characters long, this code produces an OutOfRangeException and terminates your program.

So, when using this method on strings, you have a few possibilities:

  • use this method only enclosed in a try-catch block
  • check the string length and adjust the parameters accordingly
  • or use an own method (for example a static method or an Attached method of the System.String class
exceptions.1517160315.txt.gz · Last modified: 2018/01/28 17:25 by wolfgangriedmann