Difference between revisions of "Throw"
From Mesham
Jump to navigationJump to searchm (5 revisions imported) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
== Example == | == Example == | ||
#include <io> | #include <io> | ||
− | try { | + | function void main() { |
− | + | try { | |
− | + | throw "an error" | |
− | + | } catch "an error" { | |
+ | print("Error occurred!\n"); | ||
+ | }; | ||
}; | }; | ||
In this example, a programmer defined error ''an error'' is thrown and caught. | In this example, a programmer defined error ''an error'' is thrown and caught. | ||
+ | |||
+ | ''Since: Version 0.5'' | ||
[[Category:sequential]] | [[Category:sequential]] |
Latest revision as of 15:44, 15 April 2019
Syntax
throw errorstring;
Semantics
Will throw the error string, and either cause termination of the program or, if caught by a try catch block, will be dealt with.
Example
#include <io> function void main() { try { throw "an error" } catch "an error" { print("Error occurred!\n"); }; };
In this example, a programmer defined error an error is thrown and caught.
Since: Version 0.5