trycatch
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
trycatch [2018/01/28 07:13] – created wolfgangriedmann | trycatch [2018/08/20 04:05] (current) – wolfgangriedmann | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Try - Catch ====== | ====== Try - Catch ====== | ||
- | The Try - Catch operators are very important, and should be used where an error can occurr, for example if a file that needs to be read does not exist, you are specifying an invalid path, the current user has not the rights to read and so forth - please read the documentation about [[https:// | + | The '' |
In classic VO and Win32 applications, | In classic VO and Win32 applications, | ||
Line 7: | Line 7: | ||
The .NET Framework works differently: | The .NET Framework works differently: | ||
- | A sample:< | + | A sample:< |
+ | function TestException() as void | ||
+ | local cBuffer as string | ||
+ | |||
+ | try | ||
+ | |||
+ | cBuffer := File.ReadAllText( " | ||
+ | |||
+ | catch oEx as ArgumentException | ||
+ | |||
+ | System.Console.WriteLine( " | ||
+ | |||
+ | catch oEx as NotSupportedException | ||
+ | |||
+ | System.Console.WriteLine( " | ||
+ | catch oEx as Exception | ||
+ | |||
+ | System.Console.WriteLine( "Error reading the file: " + oEx:Message ) | ||
+ | |||
+ | end try | ||
+ | |||
+ | return</ | ||
+ | |||
+ | If you don't use the '' | ||
+ | |||
+ | Please see also here: [[exceptions|Exceptions]] | ||
trycatch.1517123601.txt.gz · Last modified: 2018/01/28 07:13 by wolfgangriedmann